home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / print / pgraf130.zip / PGRAPH.DOC < prev    next >
Text File  |  1992-03-12  |  113KB  |  3,192 lines

  1.  
  2.                             PGRAPH Version 1.30
  3.  
  4.                    An MS-DOS Standard Printer Interface
  5.  
  6.  
  7.  
  8.  
  9.  
  10.  
  11.  
  12.  
  13.  
  14.  
  15.  
  16.  
  17.  
  18.  
  19.  
  20. Written and Distributed by:
  21.  
  22. Frank van der Hulst,
  23. 101 Epuni St,
  24. Lower Hutt,
  25. New Zealand
  26.  
  27. Electronic mail to:
  28. UseNet:   frank@cit.ac.nz, frank@whare.cavebbs.gen.nz
  29. FidoNet:  frank vanderhulst at GenBoard (Node 3:771/160)
  30.  
  31. Phone (Voice):      0064 4 569-3481
  32.  
  33. 12 March 1992
  34.  
  35.  
  36. ───────────────────────────────────────────────────────────────────────────
  37.  
  38. Program and Documentation Copyright Frank van der Hulst, 1991
  39. All rights reserved
  40.  
  41. Portions Copyright 1987, 1989 Borland International.
  42. Portions Copyright Microsoft Corporation.
  43.  
  44. PC-DOS, PC, PC XT, PC AT, and PS/2 are trademarks of IBM Corporation.
  45. MS-DOS, OS/2, and Windows are trademarks of Microsoft Corporation.
  46.  
  47. No part of this document may be reproduced, stored in a retrieval system,
  48. or transcribed, in any form or by any means, electronic, mechanical,
  49. photocopying, recording, scanning or otherwise, other than as stated in the
  50. license agreement, without the prior permission of:
  51.  
  52. Frank van der Hulst,
  53. 101 Epuni St,
  54. Lower Hutt,
  55. New Zealand
  56.  
  57. ───────────────────────────────────────────────────────────────────────────
  58. PGRAPH Printer Graphics Library                                     Page i.
  59.  
  60.  
  61.                              TABLE OF CONTENTS
  62.  
  63.   Introduction.......................................................1
  64.   Registration Information...........................................1
  65.   PGRAPH License Agreement...........................................2
  66.   Shareware Version:.................................................3
  67.   Registered Version:................................................3
  68.   Source Code Version:...............................................3
  69.   DISCLAIMER.........................................................4
  70.   Technical Support..................................................4
  71.   PGRAPH Features....................................................5
  72.   Minimal Memory Usage...............................................5
  73.   Video Support......................................................5
  74.   Printer Support....................................................6
  75.   Networks...........................................................6
  76.   Planned Improvements...............................................6
  77.   PGRAPH Files.......................................................7
  78.   Test Driving PGRAPH................................................8
  79.   Using PGRAPH in your own programs..................................9
  80.   Turbo-C............................................................9
  81.   MicroSoft C.......................................................10
  82.   Turbo-Pascal......................................................10
  83.   Limitations and variations from GRAPHICS.LIB/GRAPH.TPU............10
  84.   PGRAPH Function Reference.........................................13
  85.   p_arc.............................................................14
  86.   p_bar.............................................................14
  87.   p_bar3d...........................................................14
  88.   p_circle..........................................................15
  89.   p_cleardevice.....................................................15
  90.   p_clearviewport...................................................15
  91.   p_closegraph......................................................15
  92.   p_drawpoly........................................................16
  93.   p_dump............................................................16
  94.   p_ellipse.........................................................16
  95.   p_fillellipse.....................................................16
  96.   p_fillpoly........................................................17
  97.   p_floodfill.......................................................17
  98.   p_getarccoords....................................................17
  99.   p_getaspectratio..................................................18
  100.   p_getcolor........................................................18
  101.   p_getdrivername...................................................18
  102.   p_getfillpattern..................................................18
  103.   p_getfillsettings.................................................18
  104.   _p_getbyte........................................................19
  105.   p_getgraphmode....................................................19
  106.   p_getimage........................................................19
  107.   p_getlinesettings.................................................19
  108.   p_getmaxcolor.....................................................19
  109.   p_getmaxmode......................................................20
  110.   p_getmaxx.........................................................20
  111.   p_getmaxy.........................................................20
  112.   p_getmodename.....................................................20
  113.   p_getmoderange....................................................20
  114.   p_getpixel........................................................21
  115.   p_getresolution...................................................21
  116.   p_gettextsettings.................................................21
  117.   p_getx............................................................21
  118.   p_gety............................................................21
  119.   p_graphdefaults...................................................22
  120.   _p_graphfreebuff..................................................22
  121. Copyright - Frank van der Hulst/1991 PGRAPH Printer Graphics Library                                    Page ii.
  122.  
  123.   _p_graphfreemem...................................................23
  124.   _p_graphgetbuff...................................................24
  125.   _p_graphgetmem....................................................25
  126.   p_graphresult.....................................................26
  127.   p_imagesize.......................................................26
  128.   p_initgraph.......................................................27
  129.   p_line............................................................28
  130.   p_linerel.........................................................28
  131.   p_lineto..........................................................29
  132.   p_moverel.........................................................29
  133.   p_moveto..........................................................29
  134.   p_outtext.........................................................29
  135.   p_outtextxy.......................................................29
  136.   p_pieslice........................................................30
  137.   p_print...........................................................30
  138.   _p_putbyte........................................................30
  139.   p_putimage........................................................31
  140.   p_putpixel........................................................31
  141.   _p_putpixel_screen................................................32
  142.   p_rectangle.......................................................32
  143.   p_registerbgidriver...............................................32
  144.   p_registerbgifont.................................................33
  145.   p_registerfarbgidriver............................................33
  146.   p_registerfarbgifont..............................................33
  147.   p_sector..........................................................34
  148.   p_setaspectratio..................................................34
  149.   p_setcolor........................................................34
  150.   p_setfillpattern..................................................34
  151.   p_setfillstyle....................................................35
  152.   p_setgraphmode....................................................35
  153.   p_setlinestyle....................................................36
  154.   p_settextjustify..................................................37
  155.   p_settextstyle....................................................38
  156.   p_setusercharsize.................................................39
  157.   p_setviewport.....................................................40
  158.   p_setwritemode....................................................40
  159.   p_textheight......................................................41
  160.   p_textwidth.......................................................41
  161.   p_view............................................................41
  162.   MAKING A .PGI FILE................................................42
  163.   Printer Description...............................................42
  164.   Graphics Modes Descriptions.......................................43
  165.   REVISION HISTORY..................................................47
  166.   Index.............................................................49
  167.  
  168. Copyright - Frank van der Hulst/1991 PGRAPH Printer Graphics Library                                     Page 1.
  169.  
  170.  
  171.  
  172. Introduction
  173.  
  174. If you're tired of re-writing your programs for the various printers
  175. available, you'll love PGRAPH!
  176.  
  177. PGRAPH is a library of C functions designed to allow you to print graphics
  178. as easily as you can display them on the screen of your IBM PC or
  179. compatible system. It provides a BGI-like (Borland Graphics Interface) to
  180. your printer. Although these routines are written in Turbo-C, they are
  181. callable from other C languages (e.g. MicroSoft C) or from Turbo-Pascal.
  182.  
  183. PGRAPH is a library of graphics routines, similar to those provided by
  184. Borland in GRAPHICS.LIB (Turbo-C) or GRAPH.TPU (Turbo-Pascal). As such,
  185. it is a programmer's toolkit, and is not designed for the end-user. It
  186. allows you to print any graphic image, including Borland's stroked fonts,
  187. on a wide range of printers.
  188.  
  189. These functions take the same number and type of parameters as the Borland
  190. functions, so that it is a simple matter to "redirect" graphics output from
  191. the screen to your printer.
  192.  
  193. A cut-down version of PGRAPH is distributed as shareware, so that you can
  194. try it out before you decide whether you'd like to buy the full version.
  195. The complete version is available only from the author, on payment of a
  196. registration fee.
  197.  
  198. The following pages include information on registration, the PGRAPH license
  199. agreement, and technical support for PGRAPH.
  200.  
  201. Currently, there is no printed manual. Registered users get a copy of this
  202. file, formatted and ready to print on a LaserJet III, ASCII text, or in
  203. XyWrite format. If there should be sufficient demand, a printed version may
  204. be commissioned.
  205.  
  206. Registration Information
  207.  
  208. PGRAPH is a copyrighted program protected by both N.Z. and international
  209. copyright law. If you obtained PGRAPH from a shareware disk vendor, an on-
  210. line computer service or bulletin board, a friend or colleague, or another
  211. similar source, you have an unregistered (trial) copy. You are authorized
  212. to use this copy without charge for a limited period of time under the
  213. terms of the PGRAPH license agreement. After this time is up, you must
  214. register and pay for PGRAPH to continue using it.
  215.  
  216. This method of distribution is known as shareware. It allows you to
  217. determine whether PGRAPH meets your needs before you pay for it.
  218.  
  219. The registration fee for a single copy of PGRAPH is NZ$75. This is
  220. approximately US$45 at current exchange rates. Payment of this fee entitles
  221. you to:
  222.  
  223. *    A copy of PGRAPH, registered to you. This may be delivered either via
  224.      a diskette, or via E-mail. There is an additional charge of NZ$10 for
  225.      delivery via diskette.
  226.  
  227.  
  228. Copyright - Frank van der Hulst/1991 PGRAPH Printer Graphics Library                                     Page 2.
  229.  
  230.  
  231.  
  232. *    An upgrade to the next major release of PGRAPH. Upgrades may be
  233.      delivered either via E-mail, or on diskette. There is an additional
  234.      charge of NZ$10 for delivery via diskette.
  235.  
  236. *    Technical support via electronic mail or telephone.
  237.  
  238. Network, site, and corporate licenses are also available; contact the
  239. author for more information.
  240.  
  241. Source code is available at a price of NZ$125 (approximately US$70).
  242.  
  243. Please make payment by transferring the correct amount to my bank account
  244. (number 060529-0320661-00) at the Lower Hutt branch of the National Bank of
  245. New Zealand.
  246.  
  247.  
  248. PGRAPH License Agreement
  249.  
  250. The PGRAPH library and all programs and documentation distributed or
  251. shipped with it are Copyright Frank van der Hulst, 1991, and are protected
  252. by N.Z. and International copyright law. In the rest of this document, this
  253. collection of files is referred to simply as "PGRAPH". You are granted a
  254. license to use your copy of PGRAPH only under the terms and conditions
  255. specified in this license agreement.
  256.  
  257. PGRAPH is distributed in three forms:
  258.  
  259. *    A "shareware" copy of PGRAPH is a copy distributed on diskette or via
  260.      an electronic bulletin board, on-line service, or other electronic
  261.      means, obtained from a shareware disk vendor, or obtained from another
  262.      individual, and which displays the legend "shareware" on the diskette
  263.      label (if applicable). On it, the library files are called PGRAPH.LIB
  264.      and PGRAPH.TPU.
  265.  
  266. *    A "registered" copy of the PGRAPH library is a copy distributed on
  267.      diskette or via electronic mail, purchased from F van der Hulst. This
  268.      includes the Pascal source code for the PGRAPH unit, but not code for
  269.      the actual routines.
  270.  
  271. *    A "source code" copy of the PGRAPH library is a copy distributed on
  272.      diskette or via electronic mail, purchased from F van der Hulst. It
  273.      includes C and Assembler source code for all of the functions in the
  274.      PGRAPH library, and utilities associated with it.
  275.  
  276. "Printer Graphics Interface" files (with a .PGI extension), whether
  277. included in the package or developed by the user, may be freely
  278. distributed.
  279.  
  280.  
  281.  
  282.  
  283.  
  284.  
  285.  
  286.  
  287. Copyright - Frank van der Hulst/1991 PGRAPH Printer Graphics Library                                     Page 3.
  288.  
  289.  
  290. Different conditions apply to the three versions, as follows:
  291.  
  292. Shareware Version:
  293.  
  294. Shareware copies of PGRAPH are distributed to allow you to try the program
  295. before you pay for it. They are not "free" or "public domain" software. You
  296. may use PGRAPH.LIB or PGRAPH.TPU at no charge for a trial period of up to
  297. 21 days. If you wish to continue using PGRAPH after that period, you must
  298. purchase a registered copy. If you choose not to purchase a registered
  299. copy, you must stop using PGRAPH, though you may keep copies and pass them
  300. along to others.
  301.  
  302. This document, the shareware versions of the library (PGRAPH.LIB and
  303. PGRAPH.TPU), and the associated header file may be freely copied provided
  304. that:
  305.  
  306.      All of the files are copied as a group (such as in a single archive).
  307.      See below for a list of files.
  308.  
  309.      The files are not modified in any way (including removal or alteration
  310.      of copyright notices or this license).
  311.  
  312.      No charge beyond a cost-recovery fee not to exceed US$5 is made.
  313.  
  314. You may NOT distribute any program which includes code derived from the
  315. shareware version of the package.
  316.  
  317. Registered Version:
  318.  
  319. Registered copies of PGRAPH are distributed to those who have purchased
  320. them. Just like Borland's No-Nonsense License Agreement, you may install
  321. PGRAPH on many computers, so long as only one version can be used at a
  322. time. The same applies to networks.
  323.  
  324. You may copy the registered version of PGRAPH for normal backup purposes.
  325.  
  326. It may NOT be transferred to any other person or organisation without the
  327. permission of F van der Hulst.
  328.  
  329. Programs created using PGRAPH should include the following acknowledgement
  330. in their documentation:
  331.  
  332. "This program uses the PGRAPH printer graphics package developed by F van
  333. der Hulst, Wellington, New Zealand".
  334.  
  335. If you are dissatisfied with a registered copy of PGRAPH for any reason,
  336. you may erase your copy of PGRAPH from your system at any time up to 90
  337. days after purchase and receive a full refund of your original registration
  338. fee.
  339.  
  340. Registered users get a copy of this documentation file, formatted and ready
  341. to print on a LaserJet III, or in a word processor format of their choice
  342. (where possible).
  343.  
  344. Source Code Version:
  345.  
  346.  
  347. Copyright - Frank van der Hulst/1991 PGRAPH Printer Graphics Library                                     Page 4.
  348.  
  349.  
  350.  
  351. Source Code copies of PGRAPH are distributed to those who have purchased
  352. them. Just like Borland's No-Nonsense License Agreement, you may install
  353. PGRAPH on many computers, so long as only one version can be used at a
  354. time. The same applies to networks.
  355.  
  356. You may copy the source code version of PGRAPH for normal backup purposes.
  357.  
  358. This licence applies to an individual person, not to an organisation. It
  359. may NOT be transferred to any other person or organisation without the
  360. permission of F van der Hulst.
  361.  
  362. A person who has a Registered Version of PGRAPH may upgrade to the Source
  363. Code Version by paying the difference between the prices of the two
  364. versions.
  365.  
  366. Source code derived from the PGRAPH package may not be distributed in any
  367. way without the permission of F van der Hulst.
  368.  
  369. Programs created using PGRAPH should include the following acknowledgement
  370. in their documentation:
  371.  
  372. "This program uses code derived from the PGRAPH printer graphics package
  373. developed by F van der Hulst, Wellington, New Zealand".
  374.  
  375. If you are dissatisfied with a registered copy of PGRAPH for any reason,
  376. you may erase your copy of PGRAPH from your system at any time up to 90
  377. days after purchase and receive a full refund of your original registration
  378. fee.
  379.  
  380. Registered users get a copy of this documentation file, formatted and ready
  381. to print on a LaserJet III, or in a word processor format of their choice
  382. (where possible).
  383.  
  384.  
  385. DISCLAIMER
  386.  
  387. Although I have tested the code which comprises PGRAPH it is entirely
  388. possible that PGRAPH may malfunction in environments or under circumstances
  389. in which it has not been tested. This code is provided AS IS, and the
  390. author disclaims any and all responsibility for damages (both consequential
  391. and incidental) resulting from the use or misuse of PGRAPH. Sole
  392. responsibility for determining the suitability of the code rests with the
  393. user.
  394.  
  395.  
  396. Technical Support
  397.  
  398. Full technical support for PGRAPH is available only to registered users. If
  399. you are not a registered user, support is limited to assistance with the
  400. installation of a shareware copy of PGRAPH for a 21 day evaluation period.
  401.  
  402. The best way to contact me for support is via Electronic Mail, preferably
  403. via UseNet (Email address: frank@cit.ac.nz or frank@whare.cavebbs.gen.nz).
  404. Generally, a message will be acknowledged within one day of receipt. There
  405. will obviously be some delay involved in transmitting a message through a
  406. network.
  407.  
  408.  
  409. Copyright - Frank van der Hulst/1991 PGRAPH Printer Graphics Library                                     Page 5.
  410.  
  411.  
  412. Bulletin Boards: Primary support is via the "Local Software" Forum (Area 4)
  413. of Genboard BBS, Wellington, NZ 0064 4 499-0490. Genboard is attached to
  414. the FidoNet BBS Network as Node 3:771/160. You may expect a response within
  415. 3-5 days. Please note that Genboard is an independent bulletin board which
  416. has agreed to serve as a home base for PGRAPH support, but is not owned or
  417. operated by me.
  418.  
  419. In addition, registered users may contact me for support by mail, or
  420. telephone. My address and phone number are listed on the first page of this
  421. manual.
  422.  
  423. I prefer support via one of the electronic services listed above, or via
  424. electronic mail, as it allows correspondence at convenient times regardless
  425. of time zones and work schedules, and it provides a record of the
  426. communication. However, telephone support is also provided to those users
  427. who do not have a modem and need a quick response. Please check what time
  428. it is in New Zealand (usually 12 hours ahead of GMT) before you call. In
  429. general, support is only available between 5pm and 10pm NZ time.
  430.  
  431.  
  432. PGRAPH Features
  433.  
  434. PGRAPH is written for the IBM PC, PC/XT, PC/AT, PS/2 (all models), and
  435. compatibles. It was developed using Turbo C v2.01 and Turbo-Assembler. One
  436. library (PGRAPH.LIB) is provided for C. The PGRAPH.TPU file provides
  437. exactly the same features to Turbo-Pascal users.
  438.  
  439. PGRAPH.LIB is a library of graphics routines, similar to those provided by
  440. Borland in GRAPHICS.LIB. These functions perform similar tasks to, and take
  441. the same number and type of parameters as, the Borland functions.
  442.  
  443. This library should be portable to any MS-DOS C environment, since it does
  444. not call any routines which are located in Turbo C's libraries. It has been
  445. tested with Turbo C v2.01 (all memory models) and Microsoft C v5.10 (large
  446. model only).
  447.  
  448.  
  449. Minimal Memory Usage
  450.  
  451. PGRAPH is split up into several small modules, so that only the required
  452. modules are linked to the executable program to minimise the size of the
  453. executable program.
  454.  
  455. In addition, the buffer used by PGRAPH to create its raster image can be
  456. stored as a disk file (code is included in the package to do this), or in
  457. XMS or EMS. The user must provide routines to do this.
  458.  
  459. Video Support
  460.  
  461. PGRAPH allows the program to simultaneously output the image being printed
  462. to the video screen by using a user-provided pixel-display routine.
  463.  
  464.  
  465.  
  466.  
  467. Copyright - Frank van der Hulst/1991 PGRAPH Printer Graphics Library                                     Page 6.
  468.  
  469.  
  470. Printer Support
  471.  
  472. This version of PGRAPH includes drivers for the following printers:
  473.  
  474.      HP LaserJet    (series II or III)
  475.      Epson LX-400
  476.      Star NX-10
  477.      Logitech FT-5002
  478.      Star NB-15
  479.      Panasonic KX-P1124
  480.  
  481. The Epson and Star NX-10 are 9-pin dot-matrix printers, and support modes
  482. available on almost any "IBM Graphics Printer"-compatible printer. The last
  483. two are 24-pin dot-matrix printers, and support modes available on most
  484. Epson 24-pin printer clones.
  485.  
  486. Adding support for new printers is a simple process.
  487.  
  488. Networks
  489.  
  490. PGRAPH outputs to the printer by printing to stdprn, and works successfully
  491. with programs which redirect printer output. This includes networks such as
  492. Novell Netware. Output can also be redirected to other devices such as disk
  493. files from within the user program.
  494.  
  495.  
  496. Planned Improvements
  497.  
  498. Improvements will depend on registrations. If no-one registers, I'm not
  499. going to spend any more of my time on this package.
  500.  
  501. *    Support for colour printers, including allowing the programmer to set
  502.      the palette and background colour.
  503.  
  504. *    Closer integration into Borland's BGI system, including putting code
  505.      into the PGI driver file. This will allow support for plotters, and
  506.      use of (for example) the line drawing features available on the
  507.      LaserJet III.
  508.  
  509. *    Fix the bug in calculating start and end-points of arcs.
  510.  
  511. *    Fix the problem with drawing thick lines in XOR mode.
  512.  
  513. I welcome feedback on the above, and suggestions of other improvements.
  514.  
  515.  
  516.  
  517.  
  518.  
  519.  
  520.  
  521.  
  522.  
  523.  
  524.  
  525.  
  526. Copyright - Frank van der Hulst/1991 PGRAPH Printer Graphics Library                                     Page 7.
  527.  
  528.  
  529. PGRAPH Files
  530.  
  531. The files listed below are part of PGRAPH. Depending on where you obtained
  532. your copy, you may find the files in a compressed form, usually in a file
  533. with the extension .ZIP. These files may change from time to time. See the
  534. file README.DOC for up to date information on which files are included with
  535. your copy of PGRAPH.
  536.  
  537. PASCAL.ZIP          The PGRAPH demonstration program source code written in
  538.                     Turbo-Pascal. This includes the following files:
  539.  
  540.   PGRAPH.TPU        The PGRAPH library for Turbo-Pascal v6.0.
  541.  
  542.   DEMO_SUB.PAS      Subprograms needed by DEMO.PAS
  543.  
  544.   DEMO_SCR.PAS      Screen-oriented subprograms needed by DEMO.PAS
  545.  
  546.   DEMO.PAS          Main program source code for the above program.
  547.  
  548.   PGRAFBUF.PAS      Buffer management for DEMO.PAS
  549.  
  550.   TURBO.TP          Turbo-Pascal v6.0 IDE configuration file
  551.  
  552.   VARIOUS.TPU       Various data items for linking into DEMO
  553.  
  554. C.ZIP               The PGRAPH demonstration program source code written in
  555.                     C (compilable by either Turbo-C or MS C). This includes
  556.                     the following files:
  557.  
  558.   PGRAPH.LIB        The PGRAPH library for Turbo C and MS C.
  559.  
  560.   PGRAPH.H          The PGRAPH header file. This includes all the
  561.                     prototypes which allow your compiler to check that
  562.                     calls to the library are correct.
  563.  
  564.   DEMO.C            Main program source code for the above program.
  565.  
  566.   DEMO_SUB.C        Subprograms for various demonstrations to link with
  567.                     DEMO.C.
  568.  
  569.   DEMO.PRJ          Turbo C v2.0 project file used to create DEMO.EXE
  570.  
  571.   TCCONFIG.TC       Turbo C v2.0 IDE configuration file to create DEMO.EXE
  572.  
  573.   MAKE.MSC          Microsoft C MAKE file used to create DEMO.EXE
  574.  
  575.   FACE.LIB          Image of face for linking into DEMO
  576.  
  577.   PGIDRIVE.LIB      .PGI drivers for linking into DEMO
  578.  
  579. *.PGI               These files contain the interface information required
  580.                     for various printers.
  581.  
  582. MAKE_PGI.EXE        A program which allows you to create a new .PGI file.
  583.  
  584. PGRAPH.DOC          The PGRAPH manual.
  585.  
  586. DEMO.EXE            A demonstration program, created with the MicroSoft C,
  587.                     which demonstrates various features of the package.
  588.                     Compiling the source code in C.ZIP or PASCAL.ZIP will
  589.                     result in a program similar to this.
  590.  
  591. README.130          Last-minute revisions and bug reports.
  592.  
  593. In addition, the registered version of PGRAPH includes the following:
  594.  
  595.  
  596.  
  597. Copyright - Frank van der Hulst/1991 PGRAPH Printer Graphics Library                                     Page 8.
  598.  
  599.  
  600. BIN_ASM.C           A program to convert a .PGI file to an assembler source
  601.                     file, which can then be assembled and the resulting
  602.                     .OBJ file linked into a program.
  603.  
  604. MAKE_PGI.C          Source code to create MAKE_PGI.EXE
  605.  
  606. Test Driving PGRAPH
  607.  
  608. If you are running in a network environment, or wish to spool the printer
  609. output to a file, you should first set up the printer output system. For
  610. example, on a Novell Netware system, you should LOGIN and use CAPTURE to
  611. direct the output of LPT1 to your network printer.
  612.  
  613. To run the demonstration program:
  614.  
  615. *    Change to the directory DEMO.EXE is resident in
  616. *    Copy the BGI driver for your screen into the directory (CGA/EGA/VGA
  617.      and Hercules drivers are linked into the program and need not be
  618.      copied).
  619. *    Copy TRIP.CHR (the triplex font file) into the directory
  620. *    Copy any PGI drivers (except STAR and LASERJET) required into the
  621.      directory
  622. *    Execute DEMO.EXE.
  623.  
  624. DEMO.EXE can take the following command line options:
  625.  
  626.      /O=device
  627.      /P=printer_type
  628.      /M=mode
  629.      /D=demos
  630.  
  631. device allows you to redirect the PGRAPH output to another file; for
  632. example /O=STAR.PRN will output to the disk file STAR.PRN, which can later
  633. be printed using COPY/B STAR.PRN LPT1:
  634.  
  635. The default value is PRN
  636.  
  637. printer_type allows you to identify what printer is attached: valid values
  638. are STAR, LASERJET, LX400, USER1, and USER2. Default value is STAR
  639.  
  640. mode allows you to specify which printer mode to use: valid values will
  641. vary, depending on what printer is selected. See the section on p_initgraph
  642. below. The default value depends on the printer and what modes are
  643. available on it -- by default, the program will select the mode which gives
  644. sufficient X resolution to print the widest demonstration image (792 pixels
  645. wide), which on most printers will be better than 100dpi. If there are
  646. several modes with that X resolution, it will select the lowest Y
  647. resolution.
  648.  
  649.  
  650.  
  651.  
  652.  
  653.  
  654.  
  655.  
  656.  
  657.  
  658. Copyright - Frank van der Hulst/1991 PGRAPH Printer Graphics Library                                     Page 9.
  659.  
  660.  
  661. demos allows you to select which parts of the demo program to run:
  662.  
  663.      A    Draw a full page of lines, ellipses, and polygons
  664.      B    Register stroked fonts (Gothic and script), and print them in
  665.           different sizes and orientations
  666.      C    Print default font in various sizes and orientations
  667.      D    Print stroked (Triplex) and default font horizontally, using
  668.           various justification settings
  669.      E    Print stroked (Triplex) and default font vertically, using
  670.           various justification settings
  671.      F    Print stroked font (Triplex) , using various scaling factors
  672.      G    Fill various shapes with various patterns
  673.      H    Fill an arbitrary shape, using floodfill()
  674.      I    Draw various lines in different directions, with a user-defined
  675.           pattern
  676.      J    Draw circular and elliptical pie charts on the printer.
  677.      K    Display a woman's face on the printer and screen, firstly
  678.           unscaled (it was saved as an image from a CGA screen via
  679.           getimage), then scaled to fit the printer's aspect ratio as near
  680.           as possible. In between, use putimage & getimage, and p_putimage
  681.           & p_getimage, to swap characters from the printer buffer to
  682.           screen and vice versa.
  683.      L    Draw a circular pie chart on the printer, then display it on the
  684.           screen, without printing it.
  685.  
  686. By default, each demo is run in turn. This may take a long time -- for
  687. example, several hours if you have selected 240*216 mode on a dot-matrix
  688. printer and are running a slow XT.
  689.  
  690.  
  691. Using PGRAPH in your own programs
  692.  
  693. Turbo-C
  694.  
  695. The demonstration program (DEMO.C, DEMO_SUB.C, and PGRAFBUF.C) may be
  696. edited and compiled.
  697.  
  698. Use #include <PGRAPH.H> or #include "PGRAPH.H" in your source file to
  699. include the function prototypes and structure definitions from the header
  700. file at compile time. You should include PGRAPH.H after GRAPHICS.H (if you
  701. include that file), since PGRAPH.H includes definitions for various
  702. struct's which are identical to those used in the GRAPHICS.H header file.
  703.  
  704. Then use the functions provided in PGRAPH.LIB (p_initgraph(), p_putpixel(),
  705. p_closegraph(), etc.) as you would the corresponding initgraph(),
  706. putpixel(), etc.
  707.  
  708. Note that some BGI fonts and screen drivers are linked in. I have placed
  709. these in libraries for convenience. You will need to either create
  710. FONTS.LIB and BGIDRIVE.LIB, modify DEMO.PRJ, or modify the source code.
  711.  
  712. When linking, you must include PGRAPH.LIB so that code can be linked into
  713. the executable. A sample TCC line would be
  714.  
  715.      tcc -mc <other-flags> sample pgraph.lib library.lib
  716.  
  717.  
  718. Copyright - Frank van der Hulst/1991 PGRAPH Printer Graphics Library                                    Page 10.
  719.  
  720.  
  721.  
  722. The library is compatible with all memory models available in Turbo-C.
  723.  
  724. See also the section below on Limitations and variations from GRAPHICS.LIB
  725.  
  726.  
  727. MicroSoft C
  728.  
  729. The demonstration program (DEMO.C, DEMO_SUB.C, and PGRAFBUF.C) may be
  730. edited and compiled.
  731.  
  732. Use #include <PGRAPH.H> or #include "PGRAPH.H" in your source file to
  733. include the function prototypes and structure definitions from the header
  734. file at compile time. You should include PGRAPH.H after GRAPHICS.H (if you
  735. include that file), since PGRAPH.H includes definitions for various
  736. struct's which are identical to those used in the GRAPHICS.H header file.
  737.  
  738. Then use the functions provided in PGRAPH.LIB (p_initgraph(), p_putpixel(),
  739. p_closegraph(), etc.) as you would the corresponding initgraph(),
  740. putpixel(), etc.
  741.  
  742. When linking, you must include PGRAPH.LIB so that code can be linked into
  743. the executable. A sample makefile (MAKEDEMO.MSC) is included in the C.ZIP
  744. archive.
  745.  
  746. VARIOUS.LIB is provided which contains various linked-in modules which are
  747. not part of PGRAPH, but which are required for the demonstration program.
  748.  
  749. The library should be compatible with all memory models, although it has
  750. only been tested with the large model. Note that all pointers passed to the
  751. library must be far pointers, and that all calls must also be far calls.
  752.  
  753. See also the section below on Limitations and variations from GRAPHICS.LIB
  754.  
  755.  
  756. Turbo-Pascal
  757.  
  758. The demonstration program (DEMO.PAS, DEMO_SUB.PAS, DEMO_SCR.PAS, and
  759. PGRAFBUF.PAS) may be edited and compiled.
  760.  
  761. Use uses PGRAPH; in your source file to link to PGRAPH.TPU.
  762.  
  763. Then use the functions provided in PGRAPH.TPU (p_initgraph(), p_putpixel(),
  764. p_closegraph(), etc.) as you would the corresponding initgraph(),
  765. putpixel(), etc. provided by Borland's BGI.
  766.  
  767.  
  768. Limitations and variations from GRAPHICS.LIB/GRAPH.TPU
  769.  
  770. 1)   GRAPHICS.LIB includes two routines (_graphgetmem and _graphfreemem) to
  771.      allocate memory. To make it easier for a programmer to provide their
  772.      own memory allocation scheme, these have been replaced by pointers to
  773.      functions (_p_graphgetmem and _p_graphfreemem) in PGRAPH. In addition,
  774.      there are two pointers to functions called _p_graphgetbuff and
  775.  
  776.  
  777. Copyright - Frank van der Hulst/1991 PGRAPH Printer Graphics Library                                    Page 11.
  778.  
  779.  
  780.      _p_graphfreebuff which are used to allocate the bit-map buffer. All
  781.      access to the bit-map buffer is made via two more function pointers
  782.      (_p_putbyte and _p_getbyte).
  783.  
  784.      All of these function pointers MUST be initialised before p_initgraph
  785.      is called for the first time. See the file PGRAFBUF.C or PGRAFBUF.PAS
  786.      for examples of how they are used.
  787.  
  788. 2)   To facilitate echoing printed graphics to the screen, PGRAPH includes
  789.      a pointer to a function called _p_putpixel_screen. If this is set to
  790.      NULL/NIL, no screen output takes place. Otherwise the routine it
  791.      points to is executed.
  792.  
  793. 2)   PGRAPH builds up a bit map of the image to be printed in memory or in
  794.      a disk file, then prints it out when p_print() is called.
  795.  
  796. 3)   Because PGRAPH prints from a bit image, it is not suitable for
  797.      outputting to plotters. This also means it can't take advantage of the
  798.      anti-aliasing available on (for example) the LaserJet III.
  799.  
  800. 4)   Because my routines are slightly different from Borland's, some images
  801.      will be printed slightly differently from what you see on the screen.
  802.      This is true for ellipses (and all shapes based on them -- arcs,
  803.      circles, sectors, etc.) where I have used Kappel's ellipse-drawing
  804.      algorithm whereas Borland appear to have used Bresenham's. Usually the
  805.      differences are no more than one or two pixels, except where the
  806.      radius is less than three. Similarly, my line-drawing routine
  807.      sometimes selects different pixels from Borland's. These differences
  808.      will almost always be invisible, except where two shapes are drawn
  809.      close together.
  810.  
  811. 5)   As in GRAPHICS.LIB, arc start and end angles are expressed in degrees,
  812.      with 0 degrees at 3 o'clock, 90 degrees at 12 o'clock, etc. There is a
  813.      minor discrepancy in terms of calculating the start and end points of
  814.      arcs. This may result in a small gap being left between two arcs which
  815.      should end up at the same point.
  816.  
  817.      For example,
  818.  
  819.           p_arc(10, 10, 60, 90, 50);
  820.           p_arc(10, 10,  0, 60, 50);
  821.  
  822.      may not result in a complete arc from 0 to 90 degrees.
  823.  
  824. 6)   GRAPHICS.LIB only allows line, linerel, lineto, rectangle, and
  825.      drawpoly to write in XOR mode after calling setwritemode(XOR_PUT).
  826.      PGRAPH applies the mode set by p_setwritemode() to all output.
  827.  
  828. 7)   When drawing thick lines in XOR mode, the lines may be partially
  829.      erased, particularly diagonal lines and parts of arcs. This is because
  830.      these functions simply plot a 3 by 3 grid of pixels around each point
  831.      on the line, which often means that for a diagonal line the same point
  832.      may be plotted an even number of times, effectively restoring it to
  833.      its original colour.
  834.  
  835.  
  836.  
  837. Copyright - Frank van der Hulst/1991 PGRAPH Printer Graphics Library                                    Page 12.
  838.  
  839.  
  840. 8)   GRAPHICS.LIB allocates 4K (or some other amount set by calling
  841.      setgraphbufsize) for use by routines within it. PGRAPH allocates and
  842.      frees memory as it goes.
  843.  
  844. 9)   White is represented by the value 0 in PGRAPH, and black by 1. In
  845.      GRAPHICS.LIB, it's the other way round.
  846.  
  847. 10)  PGRAPH only prints in black and white.
  848.  
  849.  
  850.  
  851.  
  852.  
  853.  
  854.  
  855.  
  856.  
  857.  
  858.  
  859.  
  860.  
  861.  
  862.  
  863.  
  864.  
  865.  
  866.  
  867.  
  868.  
  869.  
  870.  
  871.  
  872.  
  873.  
  874.  
  875.  
  876.  
  877.  
  878.  
  879.  
  880.  
  881.  
  882.  
  883.  
  884.  
  885.  
  886.  
  887.  
  888.  
  889.  
  890.  
  891.  
  892.  
  893.  
  894.  
  895.  
  896. Copyright - Frank van der Hulst/1991 PGRAPH Printer Graphics Library                                    Page 13.
  897.  
  898.  
  899. PGRAPH Function Reference
  900.  
  901. PGRAPH.LIB contains over 70 functions. Most are similar to those in
  902. GRAPHICS.LIB. A few are extensions. The remainder are used within the
  903. library.
  904.  
  905. These commands are similar to those in GRAPHICS.LIB:
  906.  
  907. p_arc                  p_bar3d                p_bar
  908. p_circle               p_cleardevice          p_clearviewport
  909. p_closegraph           p_drawpoly             p_ellipse
  910. p_fillellipse          p_fillpoly             p_floodfill
  911. p_getarccoords         p_getaspectratio       p_getcolor
  912. p_getdrivername        p_getfillpattern       p_getfillsettings
  913. p_getgraphmode         p_getimage             p_getlinesettings
  914. p_getmaxcolor          p_getmaxmode           p_getmaxx
  915. p_getmaxy              p_getmodename          p_getmoderange
  916. p_getpixel             p_gettextsettings      p_getx
  917. p_gety                 p_graphdefaults        _p_graphfreemem
  918. _p_graphgetmem         p_graphresult          p_imagesize
  919. p_initgraph            p_line                 p_linerel
  920. p_lineto               p_moverel              p_moveto
  921. p_outtext              p_outtextxy            p_pieslice
  922. p_putimage             p_putpixel             p_rectangle
  923. p_registerbgidriver    p_registerbgifont      p_registerfarbgidriver
  924. p_registerfarbgifont   p_sector               p_setaspectratio
  925. p_setcolor             p_setfillpattern       p_setfillstyle
  926. p_setgraphmode         p_setlinestyle         p_settextjustify
  927. p_settextstyle         p_setusercharsize      p_setviewport
  928. p_setwritemode         p_textheight           p_textwidth
  929.  
  930. These commands are new:
  931.  
  932. p_dump                 p_getresolution        p_print
  933. _p_putpixel_screen     p_view                 _p_putbyte
  934. _p_getbyte             _p_graphgetbuff        _p_graphfreebuff
  935.  
  936.  
  937. This section describes how to call each of the PGRAPH functions.
  938.  
  939. Programmers familiar with Turbo C's or Turbo-Pascal's BGI interface, may
  940. wish to skip the following, with the exception of p_getresolution(),
  941. _p_graphfreemem, _p_graphgetmem, _p_putpixel_screen(), p_print(), p_view(),
  942. and p_dump().
  943.  
  944. In addition to the functions which are described in detail below, there are
  945. several functions in PGRAPH which are "visible" to the linker, but not
  946. described in detail below. These routines are called from within the PGRAPH
  947. library, and should not be called by external programs.
  948.  
  949. Functions are described below in alphabetical order:
  950.  
  951.  
  952.  
  953.  
  954.  
  955. Copyright - Frank van der Hulst/1991 PGRAPH Printer Graphics Library                                    Page 14.
  956.  
  957.  
  958. ---------------------------------------------------------------------------
  959. p_arc
  960. void p_arc(int x, int y, int stangle, int endangle, int radius);
  961.  
  962. Draws a circular arc in the current drawing colour, centred at (x,y) with
  963. the given radius. The arc travels from stangle to endangle, in a
  964. counterclockwise direction. The thickness of the line can be set using the
  965. thickness parameter of p_setlinestyle().
  966.  
  967. This routine allocates memory via _p_graphgetmem, and frees it again
  968. afterwards via _p_graphfreemem. If the memory is not available, a call to
  969. p_graphresult will return a value of -6.
  970.  
  971. See also: p_circle, p_ellipse, p_getarccoords, p_getaspectratio,
  972. p_graphresult, p_pieslice, p_setwritemode
  973.  
  974. ---------------------------------------------------------------------------
  975. p_bar
  976. void p_bar(int left, int top, int right, int bottom);
  977.  
  978. Draws a filled-in rectangle, using the current fill pattern and colour. The
  979. bar is not outlined.
  980.  
  981. This routine allocates memory via _p_graphgetmem, and frees it again
  982. afterwards via _p_graphfreemem. If the memory is not available, a call to
  983. p_graphresult will return a value of -6.
  984.  
  985. See also: p_bar3d, p_fillpoly, p_floodfill, p_graphresult, p_setfillstyle
  986.  
  987. ---------------------------------------------------------------------------
  988. p_bar3d
  989. void p_bar3d(int left, int top, int right, int bottom, int depth, int
  990. topflag);
  991.  
  992. Draws a three-dimensional rectangular bar, using the current line style and
  993. colour. The front face is filled in using the current fill style and
  994. colour. The depth parameter gives the bar's depth, in pixels. A depth of 0
  995. gives an outlined two-dimensional bar. If topflag is non-zero, a three-
  996. dimensional top is put on the bar, otherwise only the front face and right
  997. side are drawn. (left, top) and (right, bottom) give the pixel coordinates
  998. of the upper left and lower right corners of the rectangle.
  999.  
  1000. See also: p_bar, p_setcolor, p_setfillstyle, p_setlinestyle
  1001.  
  1002.  
  1003.  
  1004.  
  1005.  
  1006.  
  1007.  
  1008.  
  1009.  
  1010.  
  1011.  
  1012.  
  1013.  
  1014. Copyright - Frank van der Hulst/1991 PGRAPH Printer Graphics Library                                    Page 15.
  1015.  
  1016.  
  1017. ---------------------------------------------------------------------------
  1018. p_circle
  1019. void p_circle(int x, int y, int radius);
  1020.  
  1021. Draws a circle in the current drawing colour, centred at (x,y) with the
  1022. given radius. The thickness of the line can be set using the thickness
  1023. parameter of p_setlinestyle().
  1024.  
  1025. The circle will always have the correct diameter in the X direction, but
  1026. the number of pixels in the Y direction will be altered (using the current
  1027. aspect ratio) to ensure that the circle is round.
  1028.  
  1029. This routine allocates memory via _p_graphgetmem, and frees it again
  1030. afterwards via _p_graphfreemem. If the memory is not available, a call to
  1031. p_graphresult will return a value of -6.
  1032.  
  1033. See also: p_arc, p_ellipse, p_fillellipse, p_getarccoords, p_graphresult,
  1034. p_setaspectratio, p_setwritemode
  1035.  
  1036. ---------------------------------------------------------------------------
  1037. p_cleardevice
  1038. void p_cleardevice(void);
  1039.  
  1040. Clears the print buffer to zeros, and moves the graphics cursor to (0, 0).
  1041. This clears the viewport by directly writing zeros into the print buffer
  1042. memory. As such, it quickly clears the buffer. However, it does not clear
  1043. pixels drawn on the screen via _p_putpixel_screen.
  1044.  
  1045. See also: p_clearviewport, _p_putpixel_screen
  1046.  
  1047. ---------------------------------------------------------------------------
  1048. p_clearviewport
  1049. void p_clearviewport(void);
  1050.  
  1051. Clears the print buffer to zeros, and moves the graphics cursor to (0, 0).
  1052. This is done pixel by pixel, by calling p_putpixel.
  1053.  
  1054. See also: p_cleardevice, p_getviewsettings, p_putpixel, p_setviewport
  1055.  
  1056. ---------------------------------------------------------------------------
  1057. p_closegraph
  1058. void p_closegraph(void);
  1059.  
  1060. Shuts down the PGRAPH system; deallocates the memory reserved for the print
  1061. buffer, drivers, and fonts by calling _p_graphfreemem.
  1062.  
  1063. Note that this does NOT print any graphics remaining in the buffer; you
  1064. should call p_print first if necessary.
  1065.  
  1066. See also: p_initgraph, _p_graphfreemem, p_print
  1067.  
  1068.  
  1069.  
  1070.  
  1071.  
  1072.  
  1073. Copyright - Frank van der Hulst/1991 PGRAPH Printer Graphics Library                                    Page 16.
  1074.  
  1075.  
  1076. ---------------------------------------------------------------------------
  1077. p_drawpoly
  1078. void p_drawpoly(int numpoints, int far *polypoints);
  1079.  
  1080. Draws the outline of a polygon with numpoints points, using the current
  1081. line style and colour.
  1082.  
  1083. polypoints points to a sequence of x,y pairs of coordinates. In order to
  1084. draw a closed polygon, the last coordinate must be the same as the first.
  1085.  
  1086. See also: p_fillpoly, p_line, p_rectangle, p_setcolor, p_setfillstyle,
  1087. p_setlinestyle
  1088.  
  1089. ---------------------------------------------------------------------------
  1090. p_dump
  1091. void p_dump(void);
  1092.  
  1093. Dumps the contents of the print buffer to stdout in hex. For use in
  1094. debugging.
  1095.  
  1096. See also: p_view, p_print
  1097.  
  1098. ---------------------------------------------------------------------------
  1099. p_ellipse
  1100. void p_ellipse(int x, int y, int stangle, int endangle, int xradius, int
  1101. yradius);
  1102.  
  1103. Draws an elliptical arc in the current drawing colour, centred at (x,y)
  1104. with the given x and y radii. The arc travels from stangle to endangle, in
  1105. a counterclockwise direction. The thickness of the line can be set using
  1106. the thickness parameter of p_setlinestyle().
  1107.  
  1108. This routine allocates memory via _p_graphgetmem, and frees it again
  1109. afterwards via _p_graphfreemem. If the memory is not available, a call to
  1110. p_graphresult will return a value of -6.
  1111.  
  1112. See also: p_arc, p_circle, p_fillellipse, p_getaspectratio, p_graphresult,
  1113. p_sector, p_setwritemode
  1114.  
  1115. ---------------------------------------------------------------------------
  1116. p_fillellipse
  1117. void p_fillellipse( int x, int y, int xradius, int yradius );
  1118.  
  1119. Draws an ellipse in the current drawing colour, centred at (x,y) with the
  1120. given x and y radii. The thickness of the line can be set using the
  1121. thickness parameter of p_setlinestyle().
  1122.  
  1123. The interior of the ellipse is filled with the current fill colour and
  1124. pattern.
  1125.  
  1126. This routine allocates memory via _p_graphgetmem, and frees it again
  1127. afterwards via _p_graphfreemem. If the memory is not available, a call to
  1128. p_graphresult will return a value of -6.
  1129.  
  1130. See also: p_ellipse, p_fillpoly, p_getaspectratio, p_graphresult,
  1131. p_setcolor, p_setfillstyle, p_setlinestyle
  1132.  
  1133.  
  1134.  
  1135. Copyright - Frank van der Hulst/1991 PGRAPH Printer Graphics Library                                    Page 17.
  1136.  
  1137.  
  1138. ---------------------------------------------------------------------------
  1139. p_fillpoly
  1140. void p_fillpoly(int numpoints, int far *polypoints);
  1141.  
  1142. Draws the outline of a polygon with numpoints points, using the current
  1143. line style and colour. The interior of the polygon is filled with the
  1144. current fill colour and pattern.
  1145.  
  1146. polypoints points to a sequence of x,y pairs of coordinates. In order to
  1147. draw a closed polygon, the last coordinate must be the same as the first.
  1148.  
  1149. This routine allocates memory via _p_graphgetmem, and frees it again
  1150. afterwards via _p_graphfreemem. If the memory is not available, a call to
  1151. p_graphresult will return a value of -7.
  1152.  
  1153. See also: p_drawpoly, p_floodfill, p_graphresult, p_setcolor,
  1154. p_setfillstyle, p_setlinestyle
  1155.  
  1156. ---------------------------------------------------------------------------
  1157. p_floodfill
  1158. void p_floodfill(int x, int y, int border);
  1159.  
  1160. Fills an enclosed area of the bitmap. (x, y) is a "seed point" inside the
  1161. area to be filled. The area bounded by the specified border colour will be
  1162. filled with the current fill pattern and colour.
  1163.  
  1164. Where possible, p_fillpoly should be used, since it runs much faster.
  1165.  
  1166. This routine allocates memory via _p_graphgetmem, and frees it again
  1167. afterwards via _p_graphfreemem. If the memory is not available, a call to
  1168. p_graphresult will return a value of -7.
  1169.  
  1170. See also: p_drawpoly, p_fillpoly, p_graphresult, p_setcolor, p_setfillstyle
  1171.  
  1172. ---------------------------------------------------------------------------
  1173. p_getarccoords
  1174. void p_getarccoords(struct arccoordstype far *arccoords);
  1175.  
  1176. Fills the structure pointed to by arccoords with information about the last
  1177. arc (elliptical or circular) drawn. This includes information about the
  1178. centre of the arc, and the coordinates of each end of the arc. These are
  1179. useful if you need to connect a line to the end of an arc.
  1180.  
  1181. See also: p_arc, p_ellipse, p_getaspectratio
  1182.  
  1183.  
  1184.  
  1185.  
  1186.  
  1187.  
  1188.  
  1189.  
  1190.  
  1191.  
  1192.  
  1193.  
  1194. Copyright - Frank van der Hulst/1991 PGRAPH Printer Graphics Library                                    Page 18.
  1195.  
  1196.  
  1197. ---------------------------------------------------------------------------
  1198. p_getaspectratio
  1199. void p_getaspectratio(int far *xasp, int far *yasp);
  1200.  
  1201. Returns the aspect ratio of the current printer graphics mode. The value of
  1202. *yasp will usually be 10,000 or close to it; the value of *xasp depends on
  1203. the relative width and height of pixels in the current mode. If pixels are
  1204. taller than they are wide, *xasp will be less than *yasp. If pixels are
  1205. shorter than they are wide, *xasp will be greater than *yasp. If pixels are
  1206. square, *xasp and *yasp will be equal.
  1207.  
  1208. See also: p_arc, p_circle, p_pieslice, p_setaspectratio
  1209.  
  1210. ---------------------------------------------------------------------------
  1211. p_getcolor
  1212. int p_getcolor(void);
  1213.  
  1214. Returns the current drawing colour.
  1215.  
  1216. See also: p_getmaxcolor, p_setcolor
  1217.  
  1218. ---------------------------------------------------------------------------
  1219. p_getdrivername
  1220. char *p_getdrivername(void);
  1221.  
  1222. Returns a pointer to a string containing the name of the current printer.
  1223. If PGRAPH has not been initialised, returns NULL.
  1224.  
  1225. See also: p_initgraph, p_getmodename
  1226.  
  1227. ---------------------------------------------------------------------------
  1228. p_getfillpattern
  1229. void p_getfillpattern(char far *pattern);
  1230.  
  1231. Copies the user-defined fill pattern (as set by p_setfillpattern) into the
  1232. 8-byte area pointed to by pattern.
  1233.  
  1234. See also: p_setfillpattern, p_getfillsettings
  1235.  
  1236. ---------------------------------------------------------------------------
  1237. p_getfillsettings
  1238. void p_getfillsettings(struct fillsettingstype far *fillinfo);
  1239.  
  1240. Fills in the structure pointed to by fillinfo, giving information about the
  1241. current fill pattern and colour.
  1242.  
  1243. See also: p_setfillstyle
  1244.  
  1245.  
  1246.  
  1247.  
  1248.  
  1249.  
  1250.  
  1251.  
  1252.  
  1253. Copyright - Frank van der Hulst/1991 PGRAPH Printer Graphics Library                                    Page 19.
  1254.  
  1255.  
  1256. ---------------------------------------------------------------------------
  1257. _p_getbyte
  1258. unsigned char byte (*_p_getbyte)(unsigned long int offset);
  1259.  
  1260. This is a pointer to a low-level routine to read a single byte into the
  1261. bit-map buffer. All reading from the bit-map buffer is done via this
  1262. routine. The programmer must provide this routine. An example is given in
  1263. PGRAFBUF.C.
  1264.  
  1265. See also: p_cleardevice, p_getpixel, _p_putbyte, p_putpixel
  1266.  
  1267. ---------------------------------------------------------------------------
  1268. p_getgraphmode
  1269. int p_getgraphmode(void);
  1270.  
  1271. Returns the current graphics mode (set by p_initgraph or p_setgraphmode).
  1272. The enumeration p_graphics_modes, defined in PGRAPH.H, gives names for the
  1273. predefined graphics modes.
  1274.  
  1275. See also: p_getmoderange, p_initgraph, p_setgraphmode
  1276.  
  1277. ---------------------------------------------------------------------------
  1278. p_getimage
  1279. void p_getimage(int left, int top, int right, int bottom, void far
  1280. *bitmap);
  1281.  
  1282. Copies a bit image of the specified rectangle from the print buffer to
  1283. memory. (left, top) and (right, bottom) give the pixel coordinates of the
  1284. upper left and lower right corners of the rectangle. bitmap points to an
  1285. area of memory large enough to store the image. The first two words are
  1286. used to store the width and height of the image.
  1287.  
  1288. The image is stored in the same format as that used by getimage and
  1289. putimage in GRAPHICS.LIB for black and white screen images, except that
  1290. black is represented by a '1' bit, and white by a '0'.
  1291.  
  1292. See also: p_imagesize, p_putimage
  1293.  
  1294. ---------------------------------------------------------------------------
  1295. p_getlinesettings
  1296. void p_getlinesettings(struct linesettingstype far *linetypeinfo);
  1297.  
  1298. Fills in the structure pointed to by linetypeinfo, giving information about
  1299. the current line style and thickness.
  1300.  
  1301. See also: p_setlinestyle
  1302.  
  1303. ---------------------------------------------------------------------------
  1304. p_getmaxcolor
  1305. int p_getmaxcolor(void);
  1306.  
  1307. Returns the highest valid colour value (always 1).
  1308.  
  1309. See also: p_getcolor, p_setcolor
  1310.  
  1311.  
  1312.  
  1313. Copyright - Frank van der Hulst/1991 PGRAPH Printer Graphics Library                                    Page 20.
  1314.  
  1315.  
  1316. ---------------------------------------------------------------------------
  1317. p_getmaxmode
  1318. int p_getmaxmode(void);
  1319.  
  1320. Returns the highest valid mode number for the current driver. The minimum
  1321. mode is always 0.
  1322.  
  1323. See also: p_getmodename, p_getmoderange, p_setgraphmode
  1324.  
  1325. ---------------------------------------------------------------------------
  1326. p_getmaxx
  1327. int p_getmaxx(void);
  1328.  
  1329. Returns the maximum x coordinate for the current viewport. For example, if
  1330. a viewport is 2400x600, this returns 2399.
  1331.  
  1332. See also: p_getmaxy, p_getx, p_setviewport
  1333.  
  1334. ---------------------------------------------------------------------------
  1335. p_getmaxy
  1336. int p_getmaxy(void);
  1337.  
  1338. Returns the maximum y coordinate for the current viewport. For example, if
  1339. a viewport is 2400x600, this returns 599.
  1340.  
  1341. See also: p_getmaxx, p_gety, p_setviewport
  1342.  
  1343. ---------------------------------------------------------------------------
  1344. p_getmodename
  1345. char *p_getmodename(int mode_number);
  1346.  
  1347. Returns a pointer to a string containing the name of the current graphics
  1348. mode. If PGRAPH has not been initialised, returns NULL.
  1349.  
  1350. See also: p_initgraph, p_getdrivername
  1351.  
  1352. ---------------------------------------------------------------------------
  1353. p_getmoderange
  1354. void p_getmoderange(int graphdriver, int far *lomode, int far *himode);
  1355.  
  1356. Returns the range of valid mode numbers for the specified driver. The
  1357. minimum mode is always 0. If graphdriver is invalid, both *lomode and
  1358. *himode are set to -1. If graphdriver is -1, the current driver's mode
  1359. range is returned.
  1360.  
  1361. See also: p_getgraphmode, p_getmaxmode, p_getmodename, p_graph_result,
  1362. p_initgraph, p_setgraphmode
  1363.  
  1364.  
  1365.  
  1366.  
  1367.  
  1368.  
  1369.  
  1370.  
  1371.  
  1372. Copyright - Frank van der Hulst/1991 PGRAPH Printer Graphics Library                                    Page 21.
  1373.  
  1374.  
  1375. ---------------------------------------------------------------------------
  1376. p_getpixel
  1377. unsigned p_getpixel(int x, int y);
  1378.  
  1379. Returns the colour of the pixel located at (x, y).
  1380.  
  1381. All routines which read the print buffer, except for p_print and p_dump,
  1382. call p_getpixel.
  1383.  
  1384. See also: p_getimage, p_putpixel
  1385.  
  1386. ---------------------------------------------------------------------------
  1387. p_getresolution
  1388. void p_getresolution(int far *xres, int far *yres);
  1389.  
  1390. Returns the resolution in dots per inch of the current printer graphics
  1391. mode.
  1392.  
  1393. See also: p_getaspectratio, p_initgraph
  1394.  
  1395. ---------------------------------------------------------------------------
  1396. p_gettextsettings
  1397. void p_gettextsettings(struct textsettingstype far *texttypeinfo);
  1398.  
  1399. Fills in the structure pointed to by texttypeinfo, giving information about
  1400. the current font, direction, size, and justification of text.
  1401.  
  1402. See also: p_outtext, p_outtextxy, p_settextjustify, p_settextstyle,
  1403. p_setusercharsize
  1404.  
  1405. ---------------------------------------------------------------------------
  1406. p_getx
  1407. int p_getx(void);
  1408.  
  1409. Returns the graphics cursor x coordinate within the current viewport.
  1410.  
  1411. See also: p_getmaxx, p_gety, p_moveto, p_setviewport
  1412.  
  1413. ---------------------------------------------------------------------------
  1414. p_gety
  1415. int p_gety(void);
  1416.  
  1417. Returns the graphics cursor y coordinate within the current viewport.
  1418.  
  1419. See also: p_getmaxy, p_getx, p_moveto, p_setviewport
  1420.  
  1421.  
  1422.  
  1423.  
  1424.  
  1425.  
  1426.  
  1427.  
  1428.  
  1429.  
  1430.  
  1431. Copyright - Frank van der Hulst/1991 PGRAPH Printer Graphics Library                                    Page 22.
  1432.  
  1433.  
  1434. ---------------------------------------------------------------------------
  1435. p_graphdefaults
  1436. void p_graphdefaults(void);
  1437.  
  1438. Resets all graphics settings to their defaults:
  1439.                        Sets the viewport to 8 inches by 2 inches
  1440.                        Moves the graphics cursor to (0, 0)
  1441.                        Sets the drawing colour to 1 (black)
  1442.                        Sets the current fill style and pattern
  1443.                        Sets the text font and justification
  1444.  
  1445. Note that changing the viewport will free the memory allocated for the
  1446. print buffer via _p_graphfreemem, and allocate memory for the new buffer
  1447. via _p_graphgetmem. If the memory is not available, a call to p_graphresult
  1448. will return a value of -5.
  1449.  
  1450. See also: p_graphresult, p_initgraph, p_setgraphmode, p_setviewport
  1451.  
  1452. ---------------------------------------------------------------------------
  1453. _p_graphfreebuff
  1454. void (*_p_graphfreebuff)(void far *ptr, unsigned long size);
  1455.  
  1456. This is a pointer to a function which needs to be set before any PGRAPH
  1457. functions are called. It is called by various PGRAPH functions when the
  1458. size of the viewport is changed, and when the PGRAPH system is closed down.
  1459. You must point _p_graphfreebuff at a routine which frees memory allocated
  1460. by _p_graphgetbuff.
  1461.  
  1462. Normally this will point to free or farfree, but it can be replaced with a
  1463. routine to allocate memory to programs from within Extended or Expanded
  1464. memory, or to use a disk file as the buffer.
  1465.  
  1466. Examples:
  1467. Turbo C:
  1468.  
  1469.      _p_graphfreemem = farfree;
  1470.  
  1471. Microsoft C:
  1472.  
  1473.      _p_graphfreemem = hfree;
  1474.  
  1475. Programmers using other compilers should point _p_graphfreemem at the
  1476. equivalent memory allocation routine provided by their compiler vendor.
  1477.  
  1478. Both _p_graphfreebuff and _p_graphfreemem may point to the same routine.
  1479.  
  1480. See also: _p_getbyte, _p_graphgetbuff, _p_graphfreemem, _p_putbyte
  1481.  
  1482.  
  1483.  
  1484.  
  1485.  
  1486.  
  1487.  
  1488.  
  1489.  
  1490. Copyright - Frank van der Hulst/1991 PGRAPH Printer Graphics Library                                    Page 23.
  1491.  
  1492.  
  1493. ---------------------------------------------------------------------------
  1494. _p_graphfreemem
  1495. void (*_p_graphfreemem)(void far *ptr, unsigned long size);
  1496.  
  1497. This is a pointer to a function which needs to be set before any PGRAPH
  1498. functions are called. Various PGRAPH functions whenever they need to
  1499. release memory previously allocated through _p_graphgetmem. You must point
  1500. _p_graphfreemem at a routine which frees dynamically allocated memory.
  1501.  
  1502. Normally this will point to free or farfree, but it can be replaced with a
  1503. routine to allocate memory to programs from within Extended or Expanded
  1504. memory, or a disk buffer.
  1505.  
  1506. Examples:
  1507. Turbo C:
  1508.  
  1509.      _p_graphfreemem = farfree;
  1510.  
  1511. Microsoft C:
  1512.  
  1513.      _p_graphfreemem = hfree;
  1514.  
  1515. Programmers using other compilers should define _p_graphfreemem to point to
  1516. the equivalent memory allocation routine provided by their compiler vendor.
  1517.  
  1518. Note that this differs from _graphfreemem in GRAPHICS.LIB, in that it is a
  1519. pointer, rather than a function.
  1520.  
  1521. See also: _p_graphgetmem
  1522.  
  1523.  
  1524.  
  1525.  
  1526.  
  1527.  
  1528.  
  1529.  
  1530.  
  1531.  
  1532.  
  1533.  
  1534.  
  1535.  
  1536.  
  1537.  
  1538.  
  1539.  
  1540.  
  1541.  
  1542.  
  1543.  
  1544.  
  1545.  
  1546.  
  1547.  
  1548.  
  1549. Copyright - Frank van der Hulst/1991 PGRAPH Printer Graphics Library                                    Page 24.
  1550.  
  1551.  
  1552. ---------------------------------------------------------------------------
  1553. _p_graphgetbuff
  1554. void far * (*_p_graphgetbuff)(unsigned long size);
  1555.  
  1556. The routine pointed to by this variable is called by various PGRAPH
  1557. functions whenever the viewport size is changed. You must point
  1558. _p_graphgetbuff to a routine which dynamically allocates memory.
  1559.  
  1560. Normally this will point to malloc or farmalloc, but it can be replaced
  1561. with a routine to allocate memory to programs from within Extended or
  1562. Expanded memory, or a disk buffer.
  1563.  
  1564. The routines pointed to by _p_getbyte and _p_putbyte must be written to
  1565. access the bit-map buffer correctly.
  1566.  
  1567. Examples:
  1568. Turbo C:
  1569.  
  1570.      _p_graphgetmem = farmalloc;
  1571.  
  1572. Microsoft C:
  1573.  
  1574.      _p_graphgetmem = hfree;
  1575.  
  1576. Programmers using other compilers should define _p_graphgetbuff to point to
  1577. the equivalent memory allocation routine provided by their compiler vendor.
  1578.  
  1579. Both _p_graphgetbuff and _p_graphgetmem may point to the same routine.
  1580.  
  1581. See also: _p_graphfreemem, _p_getbyte, _p_putbyte
  1582.  
  1583.  
  1584.  
  1585.  
  1586.  
  1587.  
  1588.  
  1589.  
  1590.  
  1591.  
  1592.  
  1593.  
  1594.  
  1595.  
  1596.  
  1597.  
  1598.  
  1599.  
  1600.  
  1601.  
  1602.  
  1603.  
  1604.  
  1605.  
  1606.  
  1607.  
  1608. Copyright - Frank van der Hulst/1991 PGRAPH Printer Graphics Library                                    Page 25.
  1609.  
  1610.  
  1611. ---------------------------------------------------------------------------
  1612. _p_graphgetmem
  1613. void far * (*_p_graphgetmem)(unsigned long size);
  1614.  
  1615. The routine pointed to by this variable is called by various PGRAPH
  1616. functions whenever they need to dynamically allocate memory for various
  1617. buffers. You must point _p_graphgetmem to a routine which dynamically
  1618. allocates memory.
  1619.  
  1620. Normally this will point to malloc or farmalloc, but it can be replaced
  1621. with a routine to allocate memory to programs from within Extended or
  1622. Expanded memory.
  1623.  
  1624. Examples:
  1625. Turbo C:
  1626.  
  1627.      _p_graphgetmem = farmalloc;
  1628.  
  1629. Microsoft C:
  1630.  
  1631.      _p_graphgetmem = hfree;
  1632.  
  1633. Programmers using other compilers should define _p_graphgetmem to point to
  1634. the equivalent memory allocation routine provided by their compiler vendor.
  1635.  
  1636. Note that this differs from _graphgetmem in GRAPHICS.LIB, in that it is a
  1637. pointer, rather than a function.
  1638.  
  1639. See also: _p_graphfreemem
  1640.  
  1641.  
  1642.  
  1643.  
  1644.  
  1645.  
  1646.  
  1647.  
  1648.  
  1649.  
  1650.  
  1651.  
  1652.  
  1653.  
  1654.  
  1655.  
  1656.  
  1657.  
  1658.  
  1659.  
  1660.  
  1661.  
  1662.  
  1663.  
  1664.  
  1665.  
  1666.  
  1667. Copyright - Frank van der Hulst/1991 PGRAPH Printer Graphics Library                                    Page 26.
  1668.  
  1669.  
  1670. ---------------------------------------------------------------------------
  1671. p_graphresult
  1672. int p_graphresult(void);
  1673.  
  1674. This returns an error code for the last unsuccessful graphics operation,
  1675. and resets the error level to grOk. Therefore the result returned should be
  1676. stored by the calling program before testing it.
  1677.  
  1678. These codes are the same as used in GRAPHICS.LIB, therefore you can call
  1679. grapherrormsg from there to print the corresponding error message.
  1680.  
  1681. The following table list error codes returned by p_graphresult.
  1682.  
  1683.      Error          Constant            Error Message
  1684.          0          grOk                No error
  1685.         -1          grNoInitGraph       Graphics not installed (use
  1686.                                         p_initgraph)
  1687.         -2          grNotDetected       Graphics hardware not detected (not
  1688.                                         used)
  1689.         -3          grFileNotFound      Device driver file not found
  1690.         -4          grInvalidDriver     Invalid device driver file
  1691.         -5          grNoLoadMem         Not enough memory to load driver or
  1692.                                         print buffer
  1693.         -6          grNoScanMem         Out of memory when scanning ellipse
  1694.         -7          grNoFloodMem        Out of memory in flood fill
  1695.         -8          grFontNotFound      Font file not found
  1696.         -9          grNoFontMem         Not enough memory to load font
  1697.        -10          grInvalidMode       Invalid graphics mode for selected
  1698.                                         driver
  1699.        -11          grError             Graphics error
  1700.        -12          grIOerror           Graphics I/O error
  1701.        -13          grInvalidFont       Invalid font file
  1702.        -14          grInvalidFontNum    Invalid font number
  1703.        -15          grInvalidDeviceNum  Invalid device number
  1704.        -16          grInvalidVersion    Invalid version number
  1705.  
  1706. See also: graph_errors in PGRAPH.H
  1707.  
  1708. ---------------------------------------------------------------------------
  1709. p_imagesize
  1710. unsigned p_imagesize(int left, int top, int right, int bottom);
  1711.  
  1712. Returns the number of bytes required to store a bit image. If the size
  1713. required is greater than 65534 (0xFFFE), p_imagesize returns 65535
  1714. (0xFFFF).
  1715.  
  1716. See also: p_getimage, p_putimage
  1717.  
  1718.  
  1719.  
  1720.  
  1721.  
  1722.  
  1723.  
  1724.  
  1725.  
  1726. Copyright - Frank van der Hulst/1991 PGRAPH Printer Graphics Library                                    Page 27.
  1727.  
  1728.  
  1729. ---------------------------------------------------------------------------
  1730. p_initgraph
  1731. void p_initgraph(int far *graphdriver, int far *graphmode, char far
  1732. *pathtodriver);
  1733.  
  1734. This initialises the PGRAPH system by loading a graphics driver from disk
  1735. (or using a registered driver), and putting the system into the selected
  1736. graphics mode. Unlike initgraph in GRAPHICS.LIB, p_initgraph cannot auto-
  1737. detect what type of printer is attached.
  1738.  
  1739. p_initgraph first checks to see whether the selected driver has already
  1740. been loaded, or has been registered via p_registerbgidriver or
  1741. p_registerfarbgidriver. If not, it loads the driver (.PGI) file from disk,
  1742. including allocating memory for it via _p_graphgetmem.
  1743.  
  1744. p_initgraph always sets the internal error code; on success it sets it to
  1745. 0. If an error occurred, *graphdriver is set to the same value as the
  1746. internal error code.
  1747.  
  1748. pathtodriver specifies the directory path where the driver file is located.
  1749. If the file is not found in that directory, or pathtodriver is NULL,
  1750. p_initgraph looks for the file in the current directory. This is also used
  1751. by p_settextstyle to search for font (.CHR) files.
  1752.  
  1753. *graphdriver is an integer between 1 and 5 which specifies the printer
  1754. driver to be used. You give it a value using a constant of the
  1755. p_graphics_drivers enumeration type, defined in PGRAPH.H, and listed below:
  1756.  
  1757.      Value          Constant
  1758.          1          STAR
  1759.          2          LASERJET
  1760.          3          LX400
  1761.          4          USER1
  1762.          5          USER2
  1763.  
  1764. The constants USER1 and USER2 allow for up to 2 user-created drivers to be
  1765. installed and used. When one of these is used, PGRAPH first checks whether
  1766. it has been registered; if not, it loads USER1.PGI or USER2.PGI from disk.
  1767.  
  1768. *graphmode specifies the initial graphics mode. If it is not in the correct
  1769. range for the selected driver, the initialisation is aborted, and
  1770. p_graphresult will return -10. It should be selected from the following
  1771. table:
  1772.  
  1773.  
  1774.  
  1775.  
  1776.  
  1777.  
  1778.  
  1779.  
  1780.  
  1781.  
  1782.  
  1783.  
  1784.  
  1785. Copyright - Frank van der Hulst/1991 PGRAPH Printer Graphics Library                                    Page 28.
  1786.  
  1787.  
  1788.  
  1789.      Driver    Mode           Value     Resolution (dpi)
  1790.      STAR      STAR_60_72         0     60  x  72
  1791.                STAR_120_216       1     120 x 216
  1792.                STAR_120_108       2     120 x 108
  1793.                STAR_120_72        3     120 x  72
  1794.                STAR_240_216       4     240 x 216
  1795.                STAR_80_72         5      80 x  72
  1796.                STAR_72_72         6      72 x  72
  1797.                STAR_90_72         7      90 x  72
  1798.  
  1799.      LASERJET  LJ_75_75           0      75 x  75
  1800.                LJ_100_100         1     100 x 100
  1801.                LJ_150_150         2     150 x 150
  1802.                LJ_300_300         3     300 x 300
  1803.  
  1804.      LX400     LX400_60_72        0      60 x  72
  1805.                LX400_120_216      1     120 x 216
  1806.                LX400_120_108      2     120 x 108
  1807.                LX400_120_72       3     120 x  72
  1808.                LX400_240_216      4     240 x 216
  1809.                LX400_40_72        5      40 x  72
  1810.                LX400_80_72        6      80 x  72
  1811.                LX400_90_72        7      90 x  72
  1812.  
  1813.      USER1
  1814.      USER2
  1815.  
  1816. See also: p_closegraph, p_getdrivername, p_setgraphmode, p_graphdefaults,
  1817. _p_graphgetmem, p_graphresult, p_registerbgidriver, p_setgraphmode
  1818.  
  1819. ---------------------------------------------------------------------------
  1820. p_line
  1821. void p_line(int x1, int y1, int x2, int y2);
  1822.  
  1823. Draws a line from (x1, y1) to (x2, y2), using the current line style and
  1824. colour. This does not change the position of the graphics cursor.
  1825.  
  1826. See also: p_linerel, p_lineto, p_setcolor, p_setlinestyle, p_setwritemode
  1827.  
  1828. ---------------------------------------------------------------------------
  1829. p_linerel
  1830. void p_linerel(int dx, int dy);
  1831.  
  1832. Draws a line from the graphics cursor (CP) to (CP.x + dx, CP.y + dy), using
  1833. the current line style and colour. The graphics cursor is then moved to the
  1834. new point.
  1835.  
  1836. See also: p_line, p_lineto, p_setcolor, p_setlinestyle, p_setwritemode
  1837.  
  1838.  
  1839.  
  1840.  
  1841.  
  1842.  
  1843.  
  1844. Copyright - Frank van der Hulst/1991 PGRAPH Printer Graphics Library                                    Page 29.
  1845.  
  1846.  
  1847. ---------------------------------------------------------------------------
  1848. p_lineto
  1849. void p_lineto(int x, int y);
  1850.  
  1851. Draws a line from the graphics cursor to (x, y), using the current line
  1852. style and colour. The graphics cursor is then moved to (x, y).
  1853.  
  1854. See also: p_line, p_linerel, p_setcolor, p_setlinestyle, p_setwritemode
  1855.  
  1856. ---------------------------------------------------------------------------
  1857. p_moverel
  1858. void p_moverel(int dx, int dy);
  1859.  
  1860. Moves the graphics cursor (CP) to (CP.x + dx, CP.y + dy).
  1861.  
  1862. See also: p_linerel, p_moveto
  1863.  
  1864. ---------------------------------------------------------------------------
  1865. p_moveto
  1866. void p_moveto(int x, int y);
  1867.  
  1868. Moves the graphics cursor to (x, y).
  1869.  
  1870. See also: p_lineto, p_moverel, p_outtext
  1871.  
  1872. ---------------------------------------------------------------------------
  1873. p_outtext
  1874. void p_outtext(char far *textstring);
  1875.  
  1876. Displays a string at the graphics cursor in the viewport, using the current
  1877. text settings and colour. If the horizontal justification is LEFT_TEXT and
  1878. the direction is HORIZ_DIR, the graphics cursor's x coordinate is advanced
  1879. by p_textwidth(textstring). Otherwise it remains unchanged. p_textwidth and
  1880. p_textheight should be used to maintain code compatibility across several
  1881. fonts.
  1882.  
  1883. See also: p_outtextxy, p_settextjustify, p_settextstyle, p_textheight,
  1884. p_textwidth
  1885.  
  1886. ---------------------------------------------------------------------------
  1887. p_outtextxy
  1888. void p_outtextxy(int x, int y, char far *textstring);
  1889.  
  1890. Displays a string at (x, y) in the viewport, using the current text
  1891. settings and colour. The graphics cursor remains unchanged. p_textwidth and
  1892. p_textheight should be used to maintain code compatibility across several
  1893. fonts.
  1894.  
  1895. See also: p_outtext, p_settextjustify, p_settextstyle, p_textheight,
  1896. p_textwidth
  1897.  
  1898.  
  1899.  
  1900.  
  1901.  
  1902.  
  1903. Copyright - Frank van der Hulst/1991 PGRAPH Printer Graphics Library                                    Page 30.
  1904.  
  1905.  
  1906. ---------------------------------------------------------------------------
  1907. p_pieslice
  1908. void p_pieslice(int x, int y, int stangle, int endangle, int radius);
  1909.  
  1910. Draws a circular arc in the current drawing colour, centred at (x,y) with
  1911. the given radius. The arc travels from stangle to endangle, in a
  1912. counterclockwise direction. Lines are drawn from each end of the arc to (x,
  1913. y). The thickness of the lines and arc can be set using the thickness
  1914. parameter of p_setlinestyle(). The interior of the pie slice is filled
  1915. using the current fill pattern and colour.
  1916.  
  1917. This routine allocates memory via _p_graphgetmem, and frees it again
  1918. afterwards via _p_graphfreemem. If the memory is not available, a call to
  1919. p_graphresult will return a value of -6.
  1920.  
  1921. See also: p_arc, p_fillellipse, p_getarccoords, p_getaspectratio,
  1922. p_graphresult, p_sector, p_setfillstyle
  1923.  
  1924. ---------------------------------------------------------------------------
  1925. p_print
  1926. void p_print(int out_dev);
  1927.  
  1928. This routine actually prints the contents of the print buffer. To do this,
  1929. it switches the printer into graphics mode, then sends each line of pixels
  1930. to the printer. If the driver is set for a dot matrix printer, up to eight
  1931. lines of pixels may be printed at once. Finally, the printer is returned to
  1932. normal text mode.
  1933.  
  1934. Only the x part of the viewport location selected using p_setviewport is
  1935. used. Each print will begin printing at the current print position of the
  1936. printer. This means that it is possible to print an entire page by drawing
  1937. horizontal slices of it, and printing each one separately.
  1938.  
  1939. The parameter out_dev is the file handle for the output device. To output
  1940. directly to a printer, use p_print(fileno(stdprn)); Alternatively, the
  1941. output can be sent to any file. The file should be opened in binary mode.
  1942.  
  1943. See also: p_dump, p_setviewport, p_view
  1944.  
  1945. ---------------------------------------------------------------------------
  1946. _p_putbyte
  1947. void (*_p_putbyte)(unsigned long int offset, unsigned char byte);
  1948.  
  1949. This is a pointer to a low-level routine to write a single byte into the
  1950. bit-map buffer. All writing to the bit-map buffer is done via this routine.
  1951. The programmer must provide this routine. An example is given in
  1952. PGRAFBUF.C.
  1953.  
  1954. See also: p_cleardevice, _p_getbyte, p_getpixel, _p_putbyte, p_putpixel
  1955.  
  1956.  
  1957.  
  1958.  
  1959.  
  1960.  
  1961.  
  1962. Copyright - Frank van der Hulst/1991 PGRAPH Printer Graphics Library                                    Page 31.
  1963.  
  1964.  
  1965. ---------------------------------------------------------------------------
  1966. p_putimage
  1967. void p_putimage(int left, int top, void far *bitmap, int op);
  1968.  
  1969. Copies a bit image of the specified rectangle from memory to the print
  1970. buffer. (left, top) gives the viewport coordinates of the upper left corner
  1971. of the rectangle. bitmap points to the area of memory used to store the
  1972. image. The first two words contain the width and height of the image.
  1973.  
  1974. The image is stored in the same format as that used by getimage and
  1975. putimage in GRAPHICS.LIB for black and white screen images, except that
  1976. black is represented by a '1' bit, and white by a '0'.
  1977.  
  1978. The op parameter specifies how each pixel from the memory area is to be
  1979. combined with pixels in the print buffer. You give it a value using a
  1980. constant of the putimage_types enumeration type, defined in PGRAPH.H, and
  1981. listed below:
  1982.  
  1983.      Value          Constant            Description
  1984.          0          COPY_PUT            Copy
  1985.          1          XOR_PUT             exclusive or
  1986.          2          OR_PUT              inclusive or
  1987.          3          AND_PUT             and
  1988.          4          NOT_PUT             copy inverse of source
  1989.  
  1990. Often NOT_PUT is the most appropriate, since in PGRAPH 0 represents white
  1991. and 1 represents black, whereas in GRAPHICS (on the screen) 0 represents
  1992. black and 1 represents white.
  1993.  
  1994. See also: p_getimage, p_imagesize
  1995.  
  1996. ---------------------------------------------------------------------------
  1997. p_putpixel
  1998. void p_putpixel(int x, int y, int colour);
  1999.  
  2000. Plots the pixel located at (x, y) in the colour specified. Depending on the
  2001. writing mode set via p_setwritemode, this may copy the pixel to the buffer,
  2002. or else exclusive-or the pixel with the buffer.
  2003.  
  2004. This also calls _p_putpixel_screen with the same parameters as were passed
  2005. to it.
  2006.  
  2007. All output to the print buffer, except p_cleardevice, goes via p_putpixel.
  2008.  
  2009. See also: p_cleardevice, _p_getbyte, p_getpixel, p_putimage, _p_putbyte,
  2010. p_setwritemode
  2011.  
  2012.  
  2013.  
  2014.  
  2015.  
  2016.  
  2017.  
  2018.  
  2019.  
  2020.  
  2021. Copyright - Frank van der Hulst/1991 PGRAPH Printer Graphics Library                                    Page 32.
  2022.  
  2023.  
  2024. ---------------------------------------------------------------------------
  2025. _p_putpixel_screen
  2026. void (*_p_putpixel_screen)(int x, int y, int colour);
  2027.  
  2028. This is a pointer to a function which is called by p_putpixel every time it
  2029. is called. If you don't want to output to the screen, this pointer can be
  2030. set to NULL.
  2031.  
  2032. Turbo C users can copy output to the screen by pointing _p_putpixel_screen
  2033. at putpixel(). This might be useful when debugging a program.
  2034.  
  2035.      _p_putpixel_screen = putpixel;
  2036.  
  2037. People using a compiler/linker other than Turbo C could also use this as a
  2038. mechanism to get Turbo C programs to run with their own compiler, provided
  2039. that they have a routine which can plot a pixel on the screen. Note that
  2040. the routines in PGRAPH are generally much slower than the equivalent
  2041. routines in GRAPHICS.LIB, and therefore reduce the performance of programs
  2042. run this way.
  2043.  
  2044. See also: p_putpixel
  2045.  
  2046. ---------------------------------------------------------------------------
  2047. p_rectangle
  2048. void p_rectangle(int left, int top, int right, int bottom);
  2049.  
  2050. Draws a rectangle in the current line style, thickness, and colour. (left,
  2051. top) and (right, bottom) identify the upper left and lower right corners of
  2052. the rectangle.
  2053.  
  2054. See also: p_par, p_line, p_setcolor, p_setlinestyle
  2055.  
  2056. ---------------------------------------------------------------------------
  2057. p_registerbgidriver
  2058. int p_registerbgidriver(void (*driver)(void));
  2059.  
  2060. Identifies a user-loaded or linked-in graphics driver to PGRAPH. This
  2061. routine checks that the data at the given address is a valid driver; if not
  2062. it returns a negative number indicating the error. Otherwise it returns a
  2063. number which you MUST use when you call p_initgraph if you wish to use this
  2064. driver. Once its address has been passed to p_registerbgidriver,
  2065. p_initgraph will use the registered driver (rather than loading it from
  2066. disk) if that driver is called for.
  2067.  
  2068. Note that .PGI files will need to be converted into .OBJ format. The BINOBJ
  2069. program distributed by Borland as part of Turbo-Pascal is suitable for
  2070. this, although it only generates upper-case names, and the user needs to
  2071. add a leading underscore to the public name.
  2072.  
  2073. See also: p_graphresult, p_initgraph, p_registerbgifont,
  2074. p_registerfarbgidriver
  2075.  
  2076.  
  2077.  
  2078.  
  2079.  
  2080. Copyright - Frank van der Hulst/1991 PGRAPH Printer Graphics Library                                    Page 33.
  2081.  
  2082.  
  2083. ---------------------------------------------------------------------------
  2084. p_registerbgifont
  2085. int p_registerbgifont(void (*font)(void));
  2086.  
  2087. Identifies a user-loaded or linked-in font to PGRAPH. This routine checks
  2088. that the data at the given address is a valid font; if not it returns a
  2089. negative number indicating the error. Otherwise it returns a number which
  2090. you MUST use when you call p_settextstyle if you wish to use this driver.
  2091. Once its address has been passed to p_registerbgifont, p_settextstyle will
  2092. use the registered font (rather than loading it from disk) if that font is
  2093. called for.
  2094.  
  2095. Note that fonts registered for GRAPHICS.LIB via registerbgifont may also be
  2096. registered for PGRAPH.
  2097.  
  2098. See also: p_graphresult, p_initgraph, p_registerbgidriver,
  2099. p_registerfarbgifont
  2100.  
  2101. ---------------------------------------------------------------------------
  2102. p_registerfarbgidriver
  2103. int p_registerfarbgidriver(void far *driver);
  2104.  
  2105. This routine differs from p_registerbgidriver in that it allows a far
  2106. pointer as the address of driver, thus allowing drivers to be loaded on the
  2107. far heap.
  2108.  
  2109. See also: p_graphresult, p_initgraph, p_registerbgidriver,
  2110. p_registerfarbgifont
  2111.  
  2112. ---------------------------------------------------------------------------
  2113. p_registerfarbgifont
  2114. int p_registerfarbgifont(void far *font);
  2115.  
  2116. This routine differs from p_registerbgifont in that it allows a far pointer
  2117. as the address of font, thus allowing font to be loaded on the far heap.
  2118.  
  2119. See also: p_graphresult, p_initgraph, p_registerbgifont,
  2120. p_registerfarbgidriver
  2121.  
  2122.  
  2123.  
  2124.  
  2125.  
  2126.  
  2127.  
  2128.  
  2129.  
  2130.  
  2131.  
  2132.  
  2133.  
  2134.  
  2135.  
  2136.  
  2137.  
  2138.  
  2139. Copyright - Frank van der Hulst/1991 PGRAPH Printer Graphics Library                                    Page 34.
  2140.  
  2141.  
  2142. ---------------------------------------------------------------------------
  2143. p_sector
  2144. void p_sector( int X, int Y, int StAngle, int EndAngle, int XRadius, int
  2145. YRadius);
  2146.  
  2147. Draws an elliptical arc in the current drawing colour, centred at (x,y)
  2148. with the given radii. The arc travels from stangle to endangle, in a
  2149. counterclockwise direction. Lines are drawn from each end of the arc to (x,
  2150. y). The thickness of the lines and arc can be set using the thickness
  2151. parameter of p_setlinestyle. The interior of the sector is filled using the
  2152. current fill pattern and colour.
  2153.  
  2154. This routine allocates memory via _p_graphgetmem, and frees it again
  2155. afterwards via _p_graphfreemem. If the memory is not available, a call to
  2156. p_graphresult will return a value of -6.
  2157.  
  2158. See also: p_ellipse, p_fillellipse, p_getarccoords, p_getaspectratio,
  2159. p_graphresult, p_pieslice, p_setfillstyle
  2160.  
  2161. ---------------------------------------------------------------------------
  2162. p_setaspectratio
  2163. void p_setaspectratio(int xasp, int yasp);
  2164.  
  2165. This is used to change the aspect ratio of the current printer graphics
  2166. mode. The aspect ratio is used by PGRAPH to ensure that circles, circular
  2167. arcs, and pie slices are drawn correctly.
  2168.  
  2169. See also: p_arc, p_circle, p_getaspectratio, p_pieslice
  2170.  
  2171. ---------------------------------------------------------------------------
  2172. p_setcolor
  2173. void p_setcolor(int color);
  2174.  
  2175. Sets the current drawing colour to color, which can range from 0 (white) to
  2176. p_getmaxcolor, which is set to 1 (black).
  2177.  
  2178. The current drawing colour is used whenever pixels are set.
  2179.  
  2180. ---------------------------------------------------------------------------
  2181. p_setfillpattern
  2182. void p_setfillpattern(char far *upattern, int colour);
  2183.  
  2184. Copies the user-defined fill pattern in the 8-byte area pointed to by
  2185. pattern into PGRAPH. This 8 by 8 pattern is tiled across any area being
  2186. filled by p_floodfill, p_fillellipse, p_pieslice, p_sector, or p_fillpoly.
  2187. Whenever a bit in the pattern is set to 1, the corresponding pixel is
  2188. plotted.
  2189.  
  2190. See also: p_bar, p_bar3d, p_fillellipse, p_fillpoly, p_getfillpattern,
  2191. p_getfillsettings, p_pieslice, p_sector
  2192.  
  2193.  
  2194.  
  2195.  
  2196.  
  2197.  
  2198. Copyright - Frank van der Hulst/1991 PGRAPH Printer Graphics Library                                    Page 35.
  2199.  
  2200.  
  2201. ---------------------------------------------------------------------------
  2202. p_setfillstyle
  2203. void p_setfillstyle(int pattern, int colour);
  2204.  
  2205. Sets the current fill pattern and colour. To set a user-defined fill
  2206. pattern, it is better to call p_setfillpattern.
  2207.  
  2208.      Name           Value     Description
  2209.      EMPTY_FILL         0     Fill with background colour (0)
  2210.      SOLID_FILL         1     solid fill
  2211.      LINE_FILL          2     fill with ---
  2212.      LTSLASH_FILL       3     fill with ///
  2213.      SLASH_FILL         4     fill with ///, thick lines
  2214.      BKSLASH_FILL       5     fill with \\\, thick lines
  2215.      LTBKSLASH_FILL     6     fill with \\\
  2216.      HATCH_FILL         7     light hatch fill
  2217.      XHATCH_FILL        8     heavy cross-hatch fill
  2218.      INTERLEAVE_FILL    9     interleaving line fill
  2219.      WIDE_DOT_FILL     10     widely spaced dot fill
  2220.      CLOSE_DOT_FILL    11     closely spaced dot fill
  2221.      USER_FILL         12     user-defined fill pattern
  2222.  
  2223. All but EMPTY_FILL fill with the current colour; EMPTY_FILL uses the
  2224. current background colour (0).
  2225.  
  2226. If invalid input is passed to p_setfillstyle, p_graphresult will return -
  2227. 11, and the current fill settings will remain unchanged.
  2228.  
  2229. See also: p_bar, p_bar3d, p_fillellipse, p_fillpoly, p_setfillpattern,
  2230. p_getfillsettings, p_pieslice, p_sector
  2231.  
  2232. ---------------------------------------------------------------------------
  2233. p_setgraphmode
  2234. void p_setgraphmode(int mode);
  2235.  
  2236. Selects a new graphics mode. mode must be a valid mode for the current
  2237. device driver. Unlike setgraphmode in GRAPHICS.LIB, p_setgraphmode does NOT
  2238. clear the printer buffer, nor reset the graphics settings to their
  2239. defaults.
  2240.  
  2241. See also: p_getgraphmode, p_getmoderange, p_graphresult, p_initgraph
  2242.  
  2243.  
  2244.  
  2245.  
  2246.  
  2247.  
  2248.  
  2249.  
  2250.  
  2251.  
  2252.  
  2253.  
  2254.  
  2255.  
  2256.  
  2257. Copyright - Frank van der Hulst/1991 PGRAPH Printer Graphics Library                                    Page 36.
  2258.  
  2259.  
  2260. ---------------------------------------------------------------------------
  2261. p_setlinestyle
  2262. void p_setlinestyle(int linestyle, unsigned upattern, int thickness);
  2263.  
  2264. Sets the current line width and style.
  2265.  
  2266. linestyle specifies which style to use for subsequent lines. If it is
  2267. USERBIT_LINE, then upattern is used, otherwise it is ignored.
  2268.  
  2269.      Name           Value     Description
  2270.      SOLID_LINE         0     solid line
  2271.      DOTTED_LINE        1     dotted line
  2272.      CENTER_LINE        2     centered line
  2273.      DASHED_LINE        3     dashed line
  2274.      USERBIT_LINE       4     user-defined line style
  2275.  
  2276. upattern is a 16-bit pattern ; whenever a bit in the pattern is 1, the
  2277. corresponding pixel in the line is drawn in the current colour.
  2278.  
  2279. thickness specifies how wide lines are to be drawn.
  2280.  
  2281.      Name           Value     Description
  2282.      NORM_WIDTH         1     1 pixel wide
  2283.      THICK_WIDTH        3     3 pixels wide
  2284.  
  2285. If THICK_WIDTH is used, nine pixels (a 3x3 block) are drawn instead of one
  2286. for each point on a line. This has side-effects if p_setwritemode(XOR_PUT)
  2287. has been used.
  2288.  
  2289. If invalid input is passed to p_setlinestyle, p_graphresult will return -
  2290. 11, and the current line settings will remain unchanged.
  2291.  
  2292. See also: p_arc, p_bar3d, p_circle, p_drawpoly, p_ellipse, p_fillellipse,
  2293. p_getlinesettings, p_graphresult, p_line, p_linerel, p_lineto, p_pieslice,
  2294. p_rectangle
  2295.  
  2296.  
  2297.  
  2298.  
  2299.  
  2300.  
  2301.  
  2302.  
  2303.  
  2304.  
  2305.  
  2306.  
  2307.  
  2308.  
  2309.  
  2310.  
  2311.  
  2312.  
  2313.  
  2314.  
  2315.  
  2316. Copyright - Frank van der Hulst/1991 PGRAPH Printer Graphics Library                                    Page 37.
  2317.  
  2318.  
  2319. ---------------------------------------------------------------------------
  2320. p_settextjustify
  2321. void p_settextjustify(int horiz, int vert);
  2322.  
  2323. Sets text justification for p_outtext and p_outtextxy. Text will be
  2324. justified round the designated position, as specified. The default settings
  2325. are LEFT_TEXT and TOP_TEXT.
  2326.  
  2327.      Name           Value     Description
  2328.      LEFT_TEXT          0     horizontal
  2329.      CENTER_TEXT        1     horizontal and vertical
  2330.      RIGHT_TEXT         2     horizontal
  2331.      TOP_TEXT           0     vertical
  2332.      BOTTOM_TEXT        2     vertical
  2333.  
  2334. LEFT_TEXT means that text will be left-justified relative to the designated
  2335. position i.e. it will appear to the right of the designated position, etc.
  2336.  
  2337. If invalid input is passed to p_settextjustify, p_graphresult will return -
  2338. 11, and the current text settings will remain unchanged.
  2339.  
  2340. See also: p_gettextsettings, p_graphresult, p_outtext, p_outtextxy,
  2341. p_settextstyle
  2342.  
  2343.  
  2344.  
  2345.  
  2346.  
  2347.  
  2348.  
  2349.  
  2350.  
  2351.  
  2352.  
  2353.  
  2354.  
  2355.  
  2356.  
  2357.  
  2358.  
  2359.  
  2360.  
  2361.  
  2362.  
  2363.  
  2364.  
  2365.  
  2366.  
  2367.  
  2368.  
  2369.  
  2370.  
  2371.  
  2372.  
  2373.  
  2374.  
  2375. Copyright - Frank van der Hulst/1991 PGRAPH Printer Graphics Library                                    Page 38.
  2376.  
  2377.  
  2378. ---------------------------------------------------------------------------
  2379. p_settextstyle
  2380. void p_settextstyle(int font, int direction, int charsize);
  2381.  
  2382. Sets the font, direction, and size of characters to be output by p_outtext
  2383. and p_outtextxy.
  2384.  
  2385. Fonts available include one bit-mapped font, and several 'stroked' fonts.
  2386.  
  2387.      Name           Value     Filename  Description
  2388.      DEFAULT_FONT       0               8x8 bit-mapped font
  2389.      TRIPLEX_FONT       1     TRIP      Triplex
  2390.      SMALL_FONT         2     LITT      Small
  2391.      SANS_SERIF_FONT    3     SANS      Sans serif
  2392.      GOTHIC_FONT        4     GOTH      Gothic
  2393.      SCRIPT_FONT        5     SCRI      Script
  2394.      SIMPLEX_FONT       6     SIMP      Simplex
  2395.      TRI_SCR_FONT       7     TSCR      Triplex script
  2396.      COMPLEX_FONT       8     COMP      Complex
  2397.      EURO_FONT          9     EURO      Eurostyle
  2398.      BOLD_FONT         10     BOLD      Boldface
  2399.  
  2400. The default bit-mapped font is built into the BIOS of your machine. As
  2401. such, it may vary slightly from one machine to another. It is also probably
  2402. slightly different from that included in GRAPHICS.LIB. You should run the
  2403. GRAFTABL utility provided with DOS before printing any bit-mapped
  2404. characters from the extended ASCII set (i.e. characters whose ASCII value
  2405. is greater than 0x7F).
  2406.  
  2407. Stroked fonts are stored in *.CHR disk files. The first four are
  2408. distributed as part of the Turbo C package, the others are provided by
  2409. Borland and available from various sources. Normally the *.CHR file needs
  2410. to be loaded into memory before it can be used. To avoid this, you can link
  2411. font files into your program. Consult your Turbo C manual on how to do
  2412. this.
  2413.  
  2414. direction: font directions supported are horizontal (left to right) and
  2415. vertical (rotated 90 degrees counterclockwise, bottom to top). The default
  2416. direction is HORIZ_DIR.
  2417.  
  2418.      Name           Value     Description
  2419.      HORIZ_DIR          0     left to right
  2420.      VERT_DIR           1     bottom to top
  2421.  
  2422. The size of text can be magnified using the charsize factor.
  2423.  
  2424.  
  2425.  
  2426.  
  2427.  
  2428.  
  2429.  
  2430.  
  2431.  
  2432.  
  2433.  
  2434. Copyright - Frank van der Hulst/1991 PGRAPH Printer Graphics Library                                    Page 39.
  2435.  
  2436.  
  2437.      ValueBit-mapped             Stroked
  2438.          0   Invalid      p_usercharsize
  2439.          1       8x8                 40%
  2440.          2     16x16                 66%
  2441.          3     24x24                 75%
  2442.          4     32x32                100%
  2443.          5     40x40                133%
  2444.          6     48x48                166%
  2445.          7     56x56                200%
  2446.          8     64x64                250%
  2447.          9     72x72                300%
  2448.         10     80x80                400%
  2449.  
  2450. p_textheight and p_textwidth should always be used to determine the actual
  2451. dimensions of text.
  2452.  
  2453. See also: p_gettextsettings, p_graphresult, p_settextjustify,
  2454. p_setusercharsize, p_textheight, p_textwidth
  2455.  
  2456. ---------------------------------------------------------------------------
  2457. p_setusercharsize
  2458. void p_setusercharsize(int multx, int divx, int multy, int divy);
  2459.  
  2460. Allows the user to independently control the x and y scaling of text output
  2461. using stroked fonts. The scaling factors are given as a combination of
  2462. multiplier and divider. For example, to set the width to twice normal, and
  2463. the height to 1.5 times normal, use
  2464.  
  2465.      p_setusercharsize(2, 1, 3, 2);
  2466.  
  2467. See also: p_gettextsettings, p_graphresult, p_settextstyle
  2468.  
  2469.  
  2470.  
  2471.  
  2472.  
  2473.  
  2474.  
  2475.  
  2476.  
  2477.  
  2478.  
  2479.  
  2480.  
  2481.  
  2482.  
  2483.  
  2484.  
  2485.  
  2486.  
  2487.  
  2488.  
  2489.  
  2490.  
  2491.  
  2492.  
  2493. Copyright - Frank van der Hulst/1991 PGRAPH Printer Graphics Library                                    Page 40.
  2494.  
  2495.  
  2496. ---------------------------------------------------------------------------
  2497. p_setviewport
  2498. void p_setviewport(int left, int top, int right, int bottom, int clip);
  2499.  
  2500. Establishes the size and location of the viewport onto the printed page.
  2501. The viewport's corners are given in absolute pixel coordinates.
  2502.  
  2503. The width of the viewport is rounded up to a multiple of eight pixels.
  2504.  
  2505. The left coordinate is used to set the left edge of the viewport on the
  2506. printed page. The top and bottom coordinates are used only to calculate the
  2507. height of the viewport. They do NOT set the vertical position of the
  2508. viewport on the page. Graphics are always printed at the current cursor
  2509. position, so that a sequence of p_print() commands will print each viewport
  2510. in turn down the page.
  2511.  
  2512. This routine releases the current viewport by calling _p_graphfreemem, then
  2513. allocates memory for the new viewport via _p_graphgetmem. If the memory is
  2514. not available, a call to p_graphresult will return a value of -6.
  2515.  
  2516. Because p_setviewport allocates only enough memory for the selected
  2517. viewport, it is not possible to plot outside the current viewport.
  2518. Therefore, the parameter clip is used for something quite different from
  2519. setviewport in GRAPHICS.LIB. If clip is non-zero, the viewport will be
  2520. cleared within setviewport; if it is zero, the viewport will not be
  2521. cleared. If the user-provided function pointed to by _p_getgraphmem clears
  2522. the viewport (e.g. by calling calloc()), then there is no need for
  2523. setviewport to clear it again. Note that some functions internal to PGRAPH
  2524. call setviewport, and always tell it to clear the viewport.
  2525.  
  2526. See also: p_clearviewport, p_getviewsettings, p_graphresult, p_initgraph
  2527.  
  2528. ---------------------------------------------------------------------------
  2529. p_setwritemode
  2530. void p_setwritemode(int mode);
  2531.  
  2532. Sets the writing mode for printer output.
  2533.  
  2534.      Name           Value     Description
  2535.      COPY_PUT           0     Over-write existing pixel
  2536.      XOR_PUT            1     xor with existing pixel
  2537.  
  2538. Two successive XOR puts to the same location will change the pixel at that
  2539. location, then restore it again.
  2540.  
  2541. Note that this is different from setwritemode in GRAPHICS.LIB, which works
  2542. only with line-drawing functions.
  2543.  
  2544. See also: p_putimage
  2545.  
  2546.  
  2547.  
  2548.  
  2549.  
  2550.  
  2551.  
  2552. Copyright - Frank van der Hulst/1991 PGRAPH Printer Graphics Library                                    Page 41.
  2553.  
  2554.  
  2555. ---------------------------------------------------------------------------
  2556. p_textheight
  2557. int p_textheight(char far *string);
  2558.  
  2559. Uses the current font size and scaling factor to determine the height of
  2560. string in pixels. It is desirable to use p_textheight to compute the height
  2561. of strings so that code is portable across several fonts and sizes.
  2562.  
  2563. See also: p_gettextsettings, p_outtext, p_outtextxy, p_settextstyle,
  2564. p_textwidth
  2565.  
  2566. ---------------------------------------------------------------------------
  2567. p_textwidth
  2568. int p_textwidth(char far *string);
  2569.  
  2570. Uses the current font size and scaling factor to determine the width of
  2571. string in pixels. It is desirable to use p_textwidth to compute the width
  2572. of strings so that code is portable across several fonts and sizes.
  2573.  
  2574. See also: p_gettextsettings, p_outtext, p_outtextxy, p_settextstyle,
  2575. p_textheight
  2576.  
  2577. ---------------------------------------------------------------------------
  2578. p_view
  2579. void p_view(void);
  2580.  
  2581. Displays the printer buffer on the screen. This is done by calling
  2582. _p_putpixel_screen, which therefore must be defined by the user. This is
  2583. designed as a debugging tool. It is the programmer's responsibility to put
  2584. the system into graphics mode and set the appropriate viewport on the
  2585. screen beforehand, and close down the graphics system afterwards.
  2586.  
  2587. See also: p_dump, _p_putpixel_screen
  2588.  
  2589.  
  2590.  
  2591.  
  2592.  
  2593.  
  2594.  
  2595.  
  2596.  
  2597.  
  2598.  
  2599.  
  2600.  
  2601.  
  2602.  
  2603.  
  2604.  
  2605.  
  2606.  
  2607.  
  2608.  
  2609.  
  2610.  
  2611. Copyright - Frank van der Hulst/1991 PGRAPH Printer Graphics Library                                    Page 42.
  2612.  
  2613.  
  2614. MAKING A .PGI FILE
  2615.  
  2616. MAKE_PGI.EXE is a program to allow the user to create new .PGI files,
  2617. either for a printer for which a .PGI file has not yet been created, or
  2618. else to take advantage of features on an existing printer which are not
  2619. supported by the existing .PGI file.
  2620.  
  2621. Before starting to create a PGI driver, browse through your printer manual,
  2622. looking for information about printing graphics.
  2623.  
  2624. A .PGI file consists of two parts -- a description of the printer, and a
  2625. description of how to print graphics in each of its modes. MAKE_PGI leads
  2626. the user through each of these parts by asking a series of questions.
  2627.  
  2628. Printer Description
  2629.  
  2630. The first question asked is
  2631.  
  2632.      What is your name ?
  2633.  
  2634. Type in your name, or any other string you want, up to a maximum of 127
  2635. characters. This string is used to create the "copyright" message at the
  2636. beginning of the .PGI file. To see what the message looks like, use
  2637.  
  2638.      TYPE LASERJET.PGI
  2639.  
  2640. to see what is contained in the descriptive header of the LaserJet .PGI
  2641. file.
  2642.  
  2643. Next, the program asks
  2644.  
  2645.      What is the printer's name ?
  2646.  
  2647. Type in the name and model number of the printer, up to a total of 20
  2648. characters. This string will be included in the descriptive header of the
  2649. file, and a pointer to this will also be returned by the p_getdrivername
  2650. function.
  2651.  
  2652. Next, the program asks
  2653.  
  2654.      What printer ID number ?
  2655.  
  2656. You may enter a number in the range 1 to 5. This will be the number used to
  2657. select the driver when p_initgraph is called. Note that each driver
  2658. registered must have a unique ID number. For example, if you create a
  2659. driver called STAR2 with an ID number of 1, you cannot register both STAR
  2660. and STAR2. Note also that PGRAPH searches only for those files it knows
  2661. about when an unregistered driver is used, so that if you create STAR2, but
  2662. do not register it via either p_registerbgidriver or
  2663. p_registerfarbgidriver, then a call to p_initgraph will look for STAR.PGI
  2664. on the disk.
  2665.  
  2666. Next, the program asks
  2667.  
  2668.      Are numbers sent to your printer in ASCII (Y/N) ?
  2669.  
  2670.  
  2671. Copyright - Frank van der Hulst/1991 PGRAPH Printer Graphics Library                                    Page 43.
  2672.  
  2673.  
  2674.  
  2675. Most dot-matrix printers require the number of graphics bytes to be printed
  2676. to be sent as a 2-byte (16-bit) binary number. The HP LaserJet requires
  2677. that the number of bytes be sent as the ASCII representation of the number.
  2678. For example, to print 375 bytes, the LaserJet requires the characters '3',
  2679. '7', and '5' be sent to it, whereas the Star requires the bytes 77 01 (w)
  2680. be sent to it.
  2681.  
  2682. Press Y or N, depending on what your printer requires.
  2683.  
  2684. The last piece of information required is how to return from graphics mode
  2685. to text mode on the printer. The program will ask
  2686.  
  2687.      What string do you use to end graphics on your printer ?
  2688.  
  2689. You should type in a series of up to 20 characters, as described in your
  2690. printer manual, to return from graphics mode to text mode. At the end of
  2691. the string, press the F10 function key. Note that if you make a mistake,
  2692. you CANNOT use the backspace key to go back and fix the error -- you will
  2693. have to start the MAKE_PGI program over again.
  2694.  
  2695. Examples:
  2696.  
  2697. STAR NX-10 9-pin dot-matrix printer
  2698.  
  2699.      What is your name ? F van der Hulst
  2700.      What is the printer's name ? Star NX-10
  2701.      What printer ID number ? 1
  2702.      Are numbers sent to your printer in ASCII (Y/N) ? N
  2703.      What string do you use to end graphics on your printer ?
  2704.      ^[A^I^[2                                        ESC A Ctrl-I ESC 2 F10
  2705.  
  2706. This last command sets line spacing back to 9/72 inch, since the various
  2707. graphics modes alter the line spacing.
  2708.  
  2709. HP LaserJet laser printer
  2710.  
  2711.      What is your name ? F van der Hulst
  2712.      What is the printer's name ? LaserJet
  2713.      What printer ID number ? 2
  2714.      Are numbers sent to your printer in ASCII (Y/N) ? Y
  2715.      What string do you use to end graphics on your printer ?
  2716.      ^[*r0B^M                                        ESC * r 0 B Ctrl-M F10
  2717.  
  2718. This restores the printer to text mode, and issues a Carriage Return to
  2719. start text at the left-hand side of the page.
  2720.  
  2721.  
  2722. Graphics Modes Descriptions
  2723.  
  2724. Once the overall printer description has been done, you need to describe
  2725. how graphics is printed in each graphics modes in turn.
  2726.  
  2727. For each mode, answer the following questions:
  2728.  
  2729.  
  2730.  
  2731. Copyright - Frank van der Hulst/1991 PGRAPH Printer Graphics Library                                    Page 44.
  2732.  
  2733.  
  2734.      X resolution ?
  2735.  
  2736. The number of dots per inch in X resolution.
  2737.  
  2738.      Y resolution ?
  2739.  
  2740. The number of dots per inch in Y resolution.
  2741.  
  2742.      X bits per pass ?
  2743.  
  2744. This is a number, either 1 or 8, which shows how many horizontal pixels are
  2745. sent in one byte. On a LaserJet, this is 8; on dot-matrix printers, it is
  2746. 1.
  2747.  
  2748.      Y bits per pass ?
  2749.  
  2750. This is a number, either 1 or 8, which shows how many rows of pixels are
  2751. sent in one byte. On a LaserJet, this is 1; on dot-matrix printers, it is 1
  2752. or 8: 8 bits forces a vertical resolution the same as the vertical pin
  2753. spacing, whereas 1 pixel-row at a time allows a different vertical
  2754. resolution to be used.
  2755.  
  2756.      What is the mode's name ?
  2757.  
  2758. Type in the name of the mode (usually the graphics resolution), up to a
  2759. total of 20 characters. A pointer to this string will be returned by the
  2760. p_getmodename function.
  2761.  
  2762.      What string do you use to start this graphics mode on your printer
  2763.  
  2764. Type in a series of up to 20 characters, as described in your printer
  2765. manual, to start the graphics mode. This string will be sent once, at the
  2766. beginning of p_print. At the end of the string, press the F10 function key.
  2767. Note that if you make a mistake, you CANNOT use the backspace key to go
  2768. back and fix the error -- you will have to re-enter the mode again.
  2769.  
  2770.  
  2771. A line of graphics consists of several parts:
  2772.      A string of characters
  2773.      The number of graphics bytes to be sent (ASCII/Binary)
  2774.      A string of characters
  2775.      Graphics bytes
  2776.      A string of characters
  2777.  
  2778. You need to specify each of the strings of characters for each mode, by
  2779. answering the following questions:
  2780.  
  2781.      What string precedes the number in this mode ?
  2782.      What string follows the number in this mode ?
  2783.      What string ends a line of graphics in this mode ?
  2784.  
  2785. Note that entry of each of these strings is similar to entry of the "start
  2786. graphics mode" string:
  2787.      Press F10 to terminate entry
  2788.      You cannot correct any errors
  2789.      Maximum of 20 characters
  2790.  
  2791.  
  2792. Copyright - Frank van der Hulst/1991 PGRAPH Printer Graphics Library                                    Page 45.
  2793.  
  2794.  
  2795.  
  2796.  
  2797. That concludes entry of the information on a graphics mode. After each
  2798. mode, the program will ask if it is correct:
  2799.  
  2800.      Is this mode OK (Y/N) ?
  2801.  
  2802. If you made a mistake, press N and then re-enter it. If everything was
  2803. entered correctly, press Y.
  2804.  
  2805. Finally, the program will ask:
  2806.  
  2807.      Add another mode (Y/N) ?
  2808.  
  2809. If you press N, that will terminate entry of the driver data and the
  2810. program will write the data entered to USER.PGI -- you should rename it to
  2811. the correct filename.
  2812.  
  2813.  
  2814.  
  2815.  
  2816.  
  2817.  
  2818.  
  2819.  
  2820.  
  2821.  
  2822.  
  2823.  
  2824.  
  2825.  
  2826.  
  2827.  
  2828.  
  2829.  
  2830.  
  2831.  
  2832.  
  2833.  
  2834.  
  2835.  
  2836.  
  2837.  
  2838.  
  2839.  
  2840.  
  2841.  
  2842.  
  2843.  
  2844.  
  2845.  
  2846.  
  2847.  
  2848.  
  2849.  
  2850.  
  2851. Copyright - Frank van der Hulst/1991 PGRAPH Printer Graphics Library                                    Page 46.
  2852.  
  2853.  
  2854. Examples:
  2855.  
  2856. STAR NX-10 9-pin dot-matrix printer
  2857.  
  2858. Mode 0:
  2859.  
  2860.      X resolution ? 60
  2861.      Y resolution ? 72
  2862.      X bits per pass ? 1
  2863.      Y bits per pass ? 8
  2864.      What is the mode's name ? 60 * 72
  2865.      What string do you use to start this graphics mode on your printer
  2866.      ^[3^X                                                 ESC 3 Ctrl-X F10
  2867.      What string precedes the number in this mode ?
  2868.      ^[K                                                          ESC K F10
  2869.      What string follows the number in this mode ?
  2870.                                                                         F10
  2871.      What string ends a line of graphics in this mode ?
  2872.      ^M^J                                                 Ctrl-M Ctrl-J F10
  2873.      Is this mode OK (Y/N) ? Y
  2874.      Add another mode (Y/N) ? Y
  2875.  
  2876.  
  2877. Mode 1:
  2878.  
  2879.      X resolution ? 120
  2880.      Y resolution ? 216
  2881.      X bits per pass ? 1
  2882.      Y bits per pass ? 1
  2883.      What is the mode's name ? 120 * 216
  2884.      What string do you use to start this graphics mode on your printer
  2885.      ^[3^A                                                 ESC 3 Ctrl-A F10
  2886.      What string precedes the number in this mode ?
  2887.      ^[L                                                          ESC L F10
  2888.      What string follows the number in this mode ?
  2889.                                                                         F10
  2890.      What string ends a line of graphics in this mode ?
  2891.      ^M^J                                                 Ctrl-M Ctrl-J F10
  2892.      Is this mode OK (Y/N) ? Y
  2893.      Add another mode (Y/N) ? Y
  2894.  
  2895. Continue this process for the remaining 6 modes.
  2896.  
  2897. Notes:
  2898.  
  2899.      The "start graphics string" sets the linefeed spacing to the correct
  2900.      number of 1/216 of an inch, the minimum unit of Y spacing on the Star
  2901.      printer. In mode 0, this is 24/216, which equals 8/72 (8 rows of
  2902.      pixels are printed at a time). In mode 1, this 1/216, and only one row
  2903.      of pixels is printed at a time. A CR-LF pair at the end of each line
  2904.      is used to advance the printer.
  2905.  
  2906.      No string of characters is sent after the number of bytes, and the
  2907.      data bytes.
  2908.  
  2909.  
  2910.  
  2911. Copyright - Frank van der Hulst/1991 PGRAPH Printer Graphics Library                                    Page 47.
  2912.  
  2913.  
  2914.  
  2915. HP LaserJet laser printer
  2916.  
  2917. Mode 0:
  2918.  
  2919.      X resolution ? 75
  2920.      Y resolution ? 75
  2921.      X bits per pass ? 8
  2922.      Y bits per pass ? 1
  2923.      What is the mode's name ? 75 * 75
  2924.      What string do you use to start this graphics mode on your printer
  2925.      ^[&s1C^[9^[*t75R^[*r1A ESC & s 1 C ESC 9 ESC * t 7 5 R ESC * r 1 A F10
  2926.      What string precedes the number in this mode ?
  2927.      ^[*b                                                       ESC * b F10
  2928.      What string follows the number in this mode ?
  2929.      W                                                                W F10
  2930.      What string ends a line of graphics in this mode ?
  2931.                                                                         F10
  2932.      Is this mode OK (Y/N) ? Y
  2933.      Add another mode (Y/N) ? Y
  2934.  
  2935.  
  2936. Mode 1:
  2937.  
  2938.      X resolution ? 100
  2939.      Y resolution ? 100
  2940.      X bits per pass ? 8
  2941.      Y bits per pass ? 1
  2942.      What is the mode's name ? 100 * 100
  2943.      What string do you use to start this graphics mode on your printer
  2944.      ^[&s1C^[9^[*t100R^[*r1A ESC & s 1 C ESC 9 ESC * t 1 0 0 R ESC * r 1 A
  2945. F10
  2946.      What string precedes the number in this mode ?
  2947.      ^[*b                                                       ESC * b F10
  2948.      What string follows the number in this mode ?
  2949.      W                                                                W F10
  2950.      What string ends a line of graphics in this mode ?
  2951.                                                                         F10
  2952.      Is this mode OK (Y/N) ? Y
  2953.      Add another mode (Y/N) ? Y
  2954.  
  2955.  
  2956. Continue this process for the remaining 2 modes.
  2957.  
  2958. Notes:
  2959.      The "start graphics string" sets the graphics mode.
  2960.  
  2961.      The printer automatically advances at the end of each line, so no
  2962.      string of characters is sent at the end of each line.
  2963.  
  2964.  
  2965. REVISION HISTORY
  2966.  
  2967. Version        Released       Comments
  2968.  
  2969.  
  2970.  
  2971. Copyright - Frank van der Hulst/1991 PGRAPH Printer Graphics Library                                    Page 48.
  2972.  
  2973.  
  2974. 1.00           01 Apr 91      Turbo C only, pre-release
  2975. 1.01           15 Apr 91      Added MS C support.
  2976.                               Minor change to p_registerfarbgidriver
  2977. 1.10           19 Jun 91      Support for all memory models.
  2978.                               p_print parameter is handle, not FILE*
  2979.                               Serialisation removed
  2980. 1.11           07 Jul 91      Support for 24-pin printers
  2981.                               Fix bug in MAKE_PGI.EXE
  2982. 1.20           12 Jul 91      Single library links with all memory models
  2983.                               _p_graphgetmem, _p_graphfreemem,
  2984.                               _p_putpixel_screen are now pointers to
  2985.                               functions external to PGRAPH.
  2986. 1.30           14 Oct 91      Support for Turbo-Pascal.
  2987.                               Separate _p_graphgetbuff, _p_graphfreebuff
  2988.                               functions.
  2989.                               Disk buffer included.
  2990.  
  2991.  
  2992.  
  2993.  
  2994.  
  2995.  
  2996.  
  2997.  
  2998.  
  2999.  
  3000.  
  3001.  
  3002.  
  3003.  
  3004.  
  3005.  
  3006.  
  3007.  
  3008.  
  3009.  
  3010.  
  3011.  
  3012.  
  3013.  
  3014.  
  3015.  
  3016.  
  3017.  
  3018.  
  3019.  
  3020.  
  3021.  
  3022.  
  3023.  
  3024.  
  3025.  
  3026.  
  3027.  
  3028.  
  3029.  
  3030. Copyright - Frank van der Hulst/1991 PGRAPH Printer Graphics Library                                    Page 49.
  3031.  
  3032.  
  3033.                                    Index
  3034.  
  3035.   DISCLAIMER.........................................................4
  3036.   Graphics Modes Descriptions.......................................43
  3037.   Index.............................................................49
  3038.   Introduction.......................................................1
  3039.   Limitations and variations from GRAPHICS.LIB/GRAPH.TPU............10
  3040.   MAKING A .PGI FILE................................................42
  3041.   MicroSoft C.......................................................10
  3042.   Minimal Memory Usage...............................................5
  3043.   Networks...........................................................6
  3044.   PGRAPH Features....................................................5
  3045.   PGRAPH Files.......................................................7
  3046.   PGRAPH Function Reference.........................................13
  3047.   PGRAPH License Agreement...........................................2
  3048.   Planned Improvements...............................................6
  3049.   Printer Description...............................................42
  3050.   Printer Support....................................................6
  3051.   p_arc.............................................................14
  3052.   p_bar.............................................................14
  3053.   p_bar3d...........................................................14
  3054.   p_circle..........................................................15
  3055.   p_cleardevice.....................................................15
  3056.   p_clearviewport...................................................15
  3057.   p_closegraph......................................................15
  3058.   p_drawpoly........................................................16
  3059.   p_dump............................................................16
  3060.   p_ellipse.........................................................16
  3061.   p_fillellipse.....................................................16
  3062.   p_fillpoly........................................................17
  3063.   p_floodfill.......................................................17
  3064.   p_getarccoords....................................................17
  3065.   p_getaspectratio..................................................18
  3066.   p_getcolor........................................................18
  3067.   p_getdrivername...................................................18
  3068.   p_getfillpattern..................................................18
  3069.   p_getfillsettings.................................................18
  3070.   p_getgraphmode....................................................19
  3071.   p_getimage........................................................19
  3072.   p_getlinesettings.................................................19
  3073.   p_getmaxcolor.....................................................19
  3074.   p_getmaxmode......................................................20
  3075.   p_getmaxx.........................................................20
  3076.   p_getmaxy.........................................................20
  3077.   p_getmodename.....................................................20
  3078.   p_getmoderange....................................................20
  3079.   p_getpixel........................................................21
  3080.   p_getresolution...................................................21
  3081.  
  3082.  
  3083. Copyright - Frank van der Hulst/1991 PGRAPH Printer Graphics Library                                    Page 50.
  3084.  
  3085.   p_gettextsettings.................................................21
  3086.   p_getx............................................................21
  3087.   p_gety............................................................21
  3088.   p_graphdefaults...................................................22
  3089.   p_graphresult.....................................................26
  3090.   p_imagesize.......................................................26
  3091.   p_initgraph.......................................................27
  3092.   p_line............................................................28
  3093.   p_linerel.........................................................28
  3094.   p_lineto..........................................................29
  3095.   p_moverel.........................................................29
  3096.   p_moveto..........................................................29  p_outtext.........................................................29
  3097.   p_outtextxy.......................................................29
  3098.   p_pieslice........................................................30
  3099.   p_print...........................................................30
  3100.   p_putimage........................................................31
  3101.   p_putpixel........................................................31
  3102.   p_rectangle.......................................................32
  3103.   p_registerbgidriver...............................................32
  3104.   p_registerbgifont.................................................33
  3105.   p_registerfarbgidriver............................................33
  3106.   p_registerfarbgifont..............................................33
  3107.   p_sector..........................................................34
  3108.   p_setaspectratio..................................................34
  3109.   p_setcolor........................................................34
  3110.   p_setfillpattern..................................................34
  3111.   p_setfillstyle....................................................35
  3112.   p_setgraphmode....................................................35
  3113.   p_setlinestyle....................................................36
  3114.   p_settextjustify..................................................37
  3115.   p_settextstyle....................................................38
  3116.   p_setusercharsize.................................................39
  3117.   p_setviewport.....................................................40
  3118.   p_setwritemode....................................................40
  3119.   p_textheight......................................................41
  3120.   p_textwidth.......................................................41
  3121.   p_view............................................................41
  3122.   Registered Version:................................................3
  3123.   Registration Information...........................................1
  3124.   REVISION HISTORY..................................................47
  3125.   Shareware Version:.................................................3
  3126.   Source Code Version:...............................................3
  3127.   Technical Support..................................................4
  3128.   Test Driving PGRAPH................................................8
  3129.   Turbo-C............................................................9
  3130.   Turbo-Pascal......................................................10
  3131.   Using PGRAPH in your own programs..................................9
  3132.   Video Support......................................................5
  3133.   _p_getbyte........................................................19
  3134.   _p_graphfreebuff..................................................22
  3135.   _p_graphfreemem...................................................23
  3136.   _p_graphgetbuff...................................................24
  3137.   _p_graphgetmem....................................................25
  3138.   _p_putbyte........................................................30
  3139.   _p_putpixel_screen................................................32
  3140.  
  3141.  
  3142.  
  3143.  
  3144.  
  3145.  
  3146.  
  3147.  
  3148.  
  3149.  
  3150.  
  3151.  
  3152.  
  3153.  
  3154.  
  3155.  
  3156.  
  3157.  
  3158.  
  3159.  
  3160.  
  3161.  
  3162.  
  3163.  
  3164.  
  3165.  
  3166.  
  3167.  
  3168.  
  3169.  
  3170.  
  3171.  
  3172.  
  3173.  
  3174.  
  3175.  
  3176.  
  3177.  
  3178.  
  3179.  
  3180.  
  3181.  
  3182.  
  3183.  
  3184.  
  3185.  
  3186.  
  3187.  
  3188.  
  3189.  
  3190.  
  3191. Copyright - Frank van der Hulst/1991
  3192.